Esempio n. 1
0
bool SceneObject::writeField( StringTableEntry fieldName, const char* value )
{
   if( !Parent::writeField( fieldName, value ) )
      return false;
      
   static StringTableEntry sIsRenderEnabled = StringTable->insert( "isRenderEnabled" );
   static StringTableEntry sIsSelectionEnabled = StringTable->insert( "isSelectionEnabled" );
   static StringTableEntry sMountNode = StringTable->insert( "mountNode" );
   static StringTableEntry sMountPos = StringTable->insert( "mountPos" );
   static StringTableEntry sMountRot = StringTable->insert( "mountRot" );
   
   // Don't write flag fields if they are at their default values.
   
   if( fieldName == sIsRenderEnabled && dAtob( value ) )
      return false;
   else if( fieldName == sIsSelectionEnabled && dAtob( value ) )
      return false;
   else if ( mMountPID == NULL && ( fieldName == sMountNode || 
                                    fieldName == sMountPos || 
                                    fieldName == sMountRot ) )
   {
      return false;
   }

      
   return true;
}
Esempio n. 2
0
void GuiPopupMenuTextListCtrl::onMouseUp(const GuiEvent &event)
{
    Parent::onMouseUp(event);

    S32 selectionIndex = getSelectedCell().y;

    if (selectionIndex != -1)
    {
        GuiMenuBar::MenuItem *list = mMenu->firstMenuItem;

        while (selectionIndex && list)
        {
            list = list->nextMenuItem;
            selectionIndex--;
        }
        if (list)
        {
            if (list->enabled)
                dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), list->text ? list->text : ""));
        }
    }

    mSelectedCell.set(-1, -1);
    mBackground->close();
}
Esempio n. 3
0
bool TimeOfDay::setPlay( void *obj, const char *data )
{
   TimeOfDay *tod = static_cast<TimeOfDay*>(obj);
   tod->setPlay( dAtob( data ) );

   return false;
}
Esempio n. 4
0
bool NavPath::setProtectedAutoUpdate(void *obj, const char *index, const char *data)
{
   NavPath *object = static_cast<NavPath*>(obj);

   object->mAutoUpdate = dAtob(data);
   object->checkAutoUpdate();

   return false;
}
bool PopupMenu::handleSelect(U32 command, const char *text /* = NULL */)
{
   // [tom, 8/20/2006] Pass off to a sub menu if it's for them
   for(S32 i = 0;i < mSubmenus->size();i++)
   {
      PopupMenu *subM = dynamic_cast<PopupMenu *>((*mSubmenus)[i]);
      if(subM == NULL)
         continue;

      if(subM->canHandleID(command))
      {
         return subM->handleSelect(command, text);
      }
   }

   // [tom, 8/21/2006] Cheesey hack to find the position based on ID
   char buf[512];
   MENUITEMINFOA mi;
   mi.cbSize = sizeof(mi);
   mi.dwTypeData = NULL;

   S32 numItems = GetMenuItemCount(mData->mMenu);
   S32 pos = -1;
   for(S32 i = 0;i < numItems;i++)
   {
      mi.fMask = MIIM_ID|MIIM_STRING|MIIM_STATE;
      if(GetMenuItemInfoA(mData->mMenu, i, TRUE, &mi))
      {
         if(mi.wID == command)
         {
            if(text == NULL)
            {
               mi.dwTypeData = buf;
               mi.cch++;
               GetMenuItemInfoA(mData->mMenu, i, TRUE, &mi);
               
               // [tom, 5/11/2007] Don't do anything if the menu item is disabled
               if(mi.fState & MFS_DISABLED)
                  return false;

               text = StringTable->insert(mi.dwTypeData);
            }
            pos = i;
            break;
         }
      }
   }

   if(pos == -1)
   {
      Con::errorf("PopupMenu::handleSelect - Could not find menu item position for ID %d ... this shouldn't happen!", command);
      return false;
   }

   // [tom, 8/20/2006] Wasn't handled by a submenu, pass off to script
   return dAtob(Con::executef(this, "onSelectItem", Con::getIntArg(pos), text ? text : ""));
}
void GuiButtonBaseCtrl::setScriptValue(const char *value)
{
	mStateOn = dAtob(value);

	// Update the console variable:
	if ( mConsoleVariable[0] )
		Con::setBoolVariable( mConsoleVariable, mStateOn );

   setUpdate();
}
Esempio n. 7
0
TEST(Console, RuntimeClassRep)
{
   // First test to make sure that the test class is not registered (don't
   // know how it could be, but that's programming for you). Stop the test if
   // it is.
   ASSERT_TRUE(!RuntimeRegisteredSimObject::dynRTClassRep.isRegistered())
      << "RuntimeRegisteredSimObject class was already registered with the console";

   // This should not be able to find the class, and return null (this may
   // AssertWarn as well).
   ConsoleObject *conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
   EXPECT_TRUE(conobj == NULL)
      << "Unregistered AbstractClassRep returned non-NULL value! That is really bad!";

   // Register with console system.
   RuntimeRegisteredSimObject::dynRTClassRep.consoleRegister();

   // Make sure that the object knows it's registered.
   EXPECT_TRUE(RuntimeRegisteredSimObject::dynRTClassRep.isRegistered())
      << "RuntimeRegisteredSimObject class failed console registration";

   // Now try again to create the instance.
   conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
   EXPECT_TRUE(conobj != NULL)
      << "AbstractClassRep::create method failed!";

   // Cast the instance, and test it.
   RuntimeRegisteredSimObject *rtinst =
      dynamic_cast<RuntimeRegisteredSimObject *>(conobj);
   EXPECT_TRUE(rtinst != NULL)
      << "Casting failed for some reason";

   // Register it with a name.
   rtinst->registerObject("_utRRTestObject");
   EXPECT_TRUE(rtinst->isProperlyAdded())
      << "registerObject failed on test object";

   // Now execute some script on it.
   Con::evaluate("_utRRTestObject.fooField = true;");

   // Test to make sure field worked.
   EXPECT_TRUE(dAtob(rtinst->getDataField(StringTable->insert("fooField"), NULL)))
      << "Set property failed on instance.";

   // BALETED
   rtinst->deleteObject();

   // Unregister the type.
   RuntimeRegisteredSimObject::dynRTClassRep.consoleUnRegister();

   // And make sure we can't create another one.
   conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
   EXPECT_TRUE(conobj == NULL)
      << "Unregistration of type failed";
}
   bool script_simobject_getfield_bool(U32 objectId, const char* fieldName)
   {
      SimObject *object = Sim::findObject( objectId );
      if( object )
      {
         const char *v = object->getDataField(fieldName, "");

         return dAtob(v);
      }

      return false;
   }
Esempio n. 9
0
bool Portal::writeField( StringTableEntry fieldName, const char* value )
{
   static StringTableEntry sFrontSidePassable = StringTable->insert( "frontSidePassable" );
   static StringTableEntry sBackSidePassable = StringTable->insert( "backSidePassable" );

   // Don't write passable flags if at default.
   if( ( fieldName == sFrontSidePassable || fieldName == sBackSidePassable ) &&
       dAtob( value ) )
      return false;

   return Parent::writeField( fieldName, value );
}
Esempio n. 10
0
bool TSStatic::onAdd()
{
   PROFILE_SCOPE(TSStatic_onAdd);

   if ( isServerObject() )
   {
      // Handle the old "usePolysoup" field
      SimFieldDictionary* fieldDict = getFieldDictionary();

      if ( fieldDict )
      {
         StringTableEntry slotName = StringTable->insert( "usePolysoup" );

         SimFieldDictionary::Entry * entry = fieldDict->findDynamicField( slotName );

         if ( entry )
         {
            // Was "usePolysoup" set?
            bool usePolysoup = dAtob( entry->value );

            // "usePolysoup" maps to the new VisibleMesh type
            if ( usePolysoup )
               mCollisionType = VisibleMesh;

            // Remove the field in favor on the new "collisionType" field
            fieldDict->setFieldValue( slotName, "" );
         }
      }
   }

   if ( !Parent::onAdd() )
      return false;

   // Setup the shape.
   if ( !_createShape() )
   {
      Con::errorf( "TSStatic::onAdd() - Shape creation failed!" );
      return false;
   }

   setRenderTransform(mObjToWorld);

   // Register for the resource change signal.
   ResourceManager::get().getChangedSignal().notify( this, &TSStatic::_onResourceChanged );

   addToScene();

   _updateShouldTick();

   return true;
}
Esempio n. 11
0
bool PopupMenu::handleSelect(U32 command, const char *text /* = NULL */)
{
   // [tom, 8/20/2006] Pass off to a sub menu if it's for them
   for(S32 i = 0;i < mSubmenus->size();i++)
   {
      PopupMenu *subM = dynamic_cast<PopupMenu *>((*mSubmenus)[i]);
      if(subM == NULL)
         continue;

      if(subM->canHandleID(command))
      {
         return subM->handleSelect(command, text);
      }
   }

   // ensure that this menu actually has an item with the specificed command / refcon.
   // this is not strictly necessary, we're just doing it here to keep the behavior
   // in line with the windows implementation.
   UInt32 refcon;
   U32 nItems = CountMenuItems(mData->mMenu);
   S32 pos = -1;
   for(int i = 1; i <= nItems; i++)
   {
      GetMenuItemRefCon(mData->mMenu, i, &refcon);
      if(refcon == command)
         pos = i;
   }
   if(pos == -1)
   {
      Con::errorf("PopupMenu::handleSelect - Could not find menu item position for ID %d ... this shouldn't happen!", command);
      return false;
   }

   char textbuf[1024];
   if(!text)
   {
      CFStringRef cfstr;
      CopyMenuItemTextAsCFString(mData->mMenu, pos, &cfstr);
      CFStringGetCString(cfstr,textbuf,sizeof(textbuf) - 1,kCFStringEncodingUTF8);
      CFRelease( cfstr );
      text = textbuf;
   }
   
   // [tom, 8/20/2006] Wasn't handled by a submenu, pass off to script
   return dAtob(Con::executef(this, "onSelectItem", Con::getIntArg(pos - 1), text ? text : ""));
}
Esempio n. 12
0
bool WaterObject::_setFullReflect( void *object, const char *index, const char *data )
{
   WaterObject *water = static_cast<WaterObject*>( object );
   water->mFullReflect = dAtob( data );
   
   if ( water->isProperlyAdded() && water->isClientObject() )
   {
      bool isEnabled = water->mPlaneReflector.isEnabled();

      bool enable = water->mFullReflect && !smDisableTrueReflections;

      if ( enable && !isEnabled )
         water->mPlaneReflector.registerReflector( water, &water->mReflectorDesc );
      else if ( !enable && isEnabled )
         water->mPlaneReflector.unregisterReflector();
   }

   return false;
}
Esempio n. 13
0
bool ConsoleLogger::processArguments( S32 argc, const char **argv )
{
   if( argc == 0 )
      return false;

   bool append = false;

   if( argc == 2 )
      append = dAtob( argv[1] );

   mAppend = append;
   mFilename = StringTable->insert( argv[0] );

   if( init() )
   {
      attach();
      return true;
   }

   return false;
}
Esempio n. 14
0
bool SceneObject::_setSelectionEnabled( void *object, const char *index, const char *data )
{
   SceneObject* obj = reinterpret_cast< SceneObject* >( object );
   obj->setSelectionEnabled( dAtob( data ) );
   return false;
}
   addField("CallbackOnY",       TypeString,    Offset(mCallbackOnY, GuiGameListMenuCtrl));

   Parent::initPersistFields();
}

ConsoleMethod(GuiGameListMenuCtrl, addRow, void, 4, 8,
              "(string label, string callback, int icon, int yPad, bool enabled)\n"
              "Add a row to the list control.\n\n"
              "\\param label The text to display on the row as a label.\n"
              "\\param callback Name of a script function to use as a callback when this row is activated.\n"
              "\\param icon [optional] Index of the icon to use as a marker.\n"
              "\\param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
              "\\param useHighlightIcon [optional] Does this row use the highlight icon?.\n"
              "\\param enabled [optional] If this row is initially enabled.") 
{
   object->addRow(argv[2], argv[3], argc > 4 ? dAtoi(argv[4]) : -1, argc > 5 ? dAtoi(argv[5]) : 0, argc > 6 ? dAtob(argv[6]) : true, argc > 7 ? dAtob(argv[7]) : true);
}

ConsoleMethod(GuiGameListMenuCtrl, isRowEnabled, bool, 3, 3,
              "(int row)\n"
              "Determines if the specified row is enabled or disabled.\n\n"
              "\\param row The row to set the enabled status of.\n"
              "\\return (bool) True if the specified row is enabled. False if the row is not enabled or the given index was not valid.")
{
   return object->isRowEnabled(dAtoi(argv[2]));
}

ConsoleMethod(GuiGameListMenuCtrl, setRowEnabled, void, 4, 4,
              "(int row, bool enabled)\n"
              "Sets a row's enabled status according to the given parameters.\n\n"
              "\\param row The index to check for validity.\n"
Esempio n. 16
0
         {
            glArrayElement(first + i - 4);
            glArrayElement(first + i - 2);

            glArrayElement(first + i - 3);
            glArrayElement(first + i - 1);

            glArrayElement(first + i - 2);
            glArrayElement(first + i - 1);
         }
      }
      glEnd();
   }
}

ConsoleFunction(GLEnableOutline,void,2,2,"GLEnableOutline( true | false ) - sets whether to render wireframe") 
{
   gOutlineEnabled = dAtob(argv[1]);
   if(gOutlineEnabled)
   {
      glDrawElementsProcPtr = glOutlineDrawElements;
      glDrawArraysProcPtr = glOutlineDrawArrays;
      Con::printf("swapped to outline mode funcs");
   } else {
      glDrawElementsProcPtr = glDrawElements;
      glDrawArraysProcPtr = glDrawArrays;
      Con::printf("swapped to normal funcs");
   }
}
#endif
Esempio n. 17
0
 //-----------------------------------------------------------------------------
 // Bool
 //-----------------------------------------------------------------------------
 bool default_scan(const String &data, bool & result)
 {
    result = dAtob(data.c_str());
    return true;
 }
Esempio n. 18
0
bool GuiFormCtrl::_setHasMenu( void *object, const char *index, const char *data )
{
   GuiFormCtrl* ctrl = reinterpret_cast< GuiFormCtrl* >( object );
   ctrl->setHasMenu( dAtob( data ) );
   return false;
}
Esempio n. 19
0
bool getBoolVariable(const char *varName, bool def)
{
   const char *value = getVariable(varName);
   return *value ? dAtob(value) : def;
}
Esempio n. 20
0
//          The first one is the top of the stack.
//
// COUT console-output - echo of console output from engine
//
// BRKMOV file line newline - sent when a breakpoint is moved to a breakable line.
//
// BRKCLR file line - sent when a breakpoint cannot be moved to a breakable line on the client.
//


ConsoleFunction( dbgSetParameters, void, 3, 4, "(int port, string password, bool waitForClient)"
                "Open a debug server port on the specified port, requiring the specified password, "
				"and optionally waiting for the debug client to connect.")
{
   if (TelDebugger)
	   TelDebugger->setDebugParameters(dAtoi(argv[1]), argv[2], argc > 3 ? dAtob(argv[3]) : false );
}

ConsoleFunction( dbgIsConnected, bool, 1, 1, "()"
                "Returns true if a script debugging client is connected else return false.")
{
   return TelDebugger && TelDebugger->isConnected();
}

ConsoleFunction( dbgDisconnect, void, 1, 1, "()"
                "Forcibly disconnects any attached script debugging client.")
{
   if (TelDebugger)
	   TelDebugger->disconnect();
}
bool GuiBitmapButtonCtrl::_setAutoFitExtents( void *object, const char *index, const char *data )
{
    GuiBitmapButtonCtrl* ctrl = reinterpret_cast< GuiBitmapButtonCtrl* >( object );
    ctrl->setAutoFitExtents( dAtob( data ) );
    return false;
}