Esempio n. 1
0
void OptionVar::PrevValue(bool* pFastStep)
{
    bool fastStep = (pFastStep != NULL && *pFastStep);
    switch (Type)
    {
    case Type_Enum:
        *AsInt() = ((GetEnumIndex() + (UInt32)EnumValues.GetSize() - 1) % EnumValues.GetSize());
        break;

    case Type_Int:
        *AsInt() = Alg::Max<SInt32>(*AsInt() - StepInt * (fastStep ? 5 : 1), MinInt);
        break;

    case Type_Float:
        // TODO: Will behave strange with NaN values.
        *AsFloat() = Alg::Max<float>(*AsFloat() - StepFloat * (fastStep ? 5.0f : 1.0f), MinFloat);
        break;

    case Type_Bool:
        *AsBool() = !*AsBool();
        break;
    }

    SignalUpdate();
}
Esempio n. 2
0
uint EnumData::GetEnum(const string & name) const
{
  //Loop and retrieve
  int index = GetEnumIndex(name);
  if(index != -1)
  {
    return enumValues[index].value;
  }

  return (uint)-1;
}
Esempio n. 3
0
const string & EnumData::GetEnum(uint value) const
{
  //Retrieve the index
  int index = GetEnumIndex(value);
  if(index != -1)
  {
    return enumValues[index].name;
  }

  return unknownValueStr;
}
Esempio n. 4
0
string EnumData::GetDisplayString(uint value) const
{
  //Check for a bit mask 
  if(!isBitMask)
  {
    //Look for the value
    int index = GetEnumIndex(value);
    if(index != -1)
    {
      return enumValues[index].name;
    }
    else
    {
      //Add the value to the buffer
      string retString;
      StringPrintF(retString,"0x%04x",value);
      return retString;
    }

  }
  else
  {
    string bitMaskStr;
    bool  firstBit =true;

    //Loop and test all bits
    for(uint i=0;i<sizeof(uint)*8;i++)
    {
      uint mask = ((uint)1 << i);

      //Test if the mask value is used
      if(value & mask)
      {
        //Add a seperator
        if(!firstBit)
        {
          bitMaskStr = bitMaskStr  + " | ";
        }
        else
        {
          firstBit =false;
        }

        //Look-up the mask value
        int index = GetEnumIndex(mask);
        if(index != -1)
        {
          bitMaskStr = bitMaskStr + enumValues[index].name;
        }
        else
        {
          //Add the mask value to the buffer
          string retString;
          StringPrintF(retString,"0x%04x",mask);
          bitMaskStr = bitMaskStr + retString;
        }
      }
    }

    //Assign a zero string for no bits
    if(firstBit)
    {
      //Ensure this is no "zero mask" value
      int index = GetEnumIndex(value);
      if(index != -1)
      {
        return enumValues[index].name;
      }
      else
      {
        bitMaskStr = "0x000000";
      }
    }

    //Return the mask
    return bitMaskStr;
  }

}