void InterfaceWindow::CreateValueControl( char *name, int x, int y, int w, int h, int dataType, void *value, float change, float _lowBound, float _highBound, InterfaceButton *callback, char *tooltip, bool tooltipIsLanguagePhrase ) { InputField *input = new InputField(); if( dataType == InputField::TypeString ) { input->SetProperties( name, x, y, w, h, name, tooltip, false, tooltipIsLanguagePhrase ); } else { input->SetProperties( name, x+h+2, y, w-h*2-4, h, name, tooltip, false, tooltipIsLanguagePhrase ); } input->m_lowBound = _lowBound; input->m_highBound = _highBound; input->SetCallback( callback ); switch( dataType ) { case InputField::TypeChar: input->RegisterChar ( (unsigned char *) value ); break; case InputField::TypeInt: input->RegisterInt ( (int *) value ); break; case InputField::TypeFloat: input->RegisterFloat ( (float *) value ); break; case InputField::TypeString: input->RegisterString ( (char *) value ); break; } RegisterButton( input ); if( dataType != InputField::TypeString ) { char nameLeft[64]; sprintf( nameLeft, "%s left", name ); InputScroller *left = new InputScroller(); left->SetProperties( nameLeft, input->m_x - h-2, y, h, h, " ", "dialog_decrease", false, true ); left->m_inputField = input; left->m_change = -change; RegisterButton( left ); char nameRight[64]; sprintf( nameRight, "%s right", name ); InputScroller *right = new InputScroller(); right->SetProperties( nameRight, input->m_x + input->m_w+2, y, h, h, " ", "dialog_increase", false, true ); right->m_inputField = input; right->m_change = change; RegisterButton( right ); } }
void BuildingEditWindow::Create() { DarwiniaWindow::Create(); Building *building = g_app->m_location->GetBuilding(g_app->m_locationEditor->m_selectionId); DarwiniaDebugAssert(building); int buttonPitch = 18; int y = 6; ToolButton *mb = new ToolButton(LocationEditor::ToolMove); mb->SetShortProperties(LANGUAGEPHRASE("editor_move"), 10, y += buttonPitch, m_w-20); RegisterButton(mb); ToolButton *rb = new ToolButton(LocationEditor::ToolRotate); rb->SetShortProperties(LANGUAGEPHRASE("editor_rotate"), 10, y += buttonPitch, m_w-20); RegisterButton(rb); CloneBuildingButton *clone = new CloneBuildingButton(); clone->SetShortProperties(LANGUAGEPHRASE("editor_clone"), 10, y+=buttonPitch, m_w-20); RegisterButton(clone); DeleteBuildingButton *db = new DeleteBuildingButton(); db->SetShortProperties(LANGUAGEPHRASE("editor_delete"), 10, y += buttonPitch, m_w-20); RegisterButton(db); ToolButton *lb = new ToolButton(LocationEditor::ToolLink); lb->SetShortProperties(LANGUAGEPHRASE("editor_link"), 10, y += buttonPitch, m_w-20); RegisterButton(lb); y += buttonPitch; for( int i = -1; i < 3; ++i ) { char name[256]; int w = m_w/4 - 5; sprintf( name, "T%d",i); TeamButton *tb = new TeamButton(i); tb->SetShortProperties(name, 61 + (float)i*((float)w + 1.0f), y, w - 2); RegisterButton(tb); } CreateValueControl(LANGUAGEPHRASE("editor_dynamic"), InputField::TypeChar, &building->m_dynamic, y += buttonPitch, 1.0f, 0, 1); CreateValueControl(LANGUAGEPHRASE("editor_isglobal"), InputField::TypeChar, &building->m_isGlobal, y += buttonPitch, 1.0f, 0, 1); if (building->m_type == Building::TypeFactory) { InputField *intExtra = new InputField(); intExtra->SetShortProperties(LANGUAGEPHRASE("editor_spirits"), 10, y += buttonPitch, m_w-20); Factory *factory = (Factory*)building; intExtra->RegisterInt(&factory->m_initialCapacity); RegisterButton(intExtra); } else if (building->m_type == Building::TypeTrunkPort) { InputField *inExtra = new InputField(); inExtra->SetShortProperties(LANGUAGEPHRASE("editor_targetlocation"), 10, y += buttonPitch, m_w-20); TrunkPort *port = (TrunkPort *) building; inExtra->RegisterInt( &port->m_targetLocationId ); RegisterButton(inExtra); } else if (building->m_type == Building::TypeLaserFence) { LaserFence *fence = (LaserFence *) building; CreateValueControl( LANGUAGEPHRASE("editor_scale"), InputField::TypeFloat, &fence->m_scale, y+=buttonPitch, 0.01f, 0.0f, 100.0f ); DropDownMenu *menu = new DropDownMenu(true); menu->SetShortProperties( LANGUAGEPHRASE("editor_mode"), 10, y+=buttonPitch, m_w-20 ); menu->AddOption( LANGUAGEPHRASE("editor_disabled") ); menu->AddOption( LANGUAGEPHRASE("editor_enabling") ); menu->AddOption( LANGUAGEPHRASE("editor_enabled") ); menu->AddOption( LANGUAGEPHRASE("editor_disabling") ); menu->AddOption( LANGUAGEPHRASE("editor_neveron") ); menu->RegisterInt( &fence->m_mode ); RegisterButton( menu ); } else if(building->m_type == Building::TypeAntHill) { AntHill *antHill = (AntHill *) building; CreateValueControl( LANGUAGEPHRASE("editor_numants"), InputField::TypeInt, &antHill->m_numAntsInside, y+=buttonPitch, 1, 0, 1000 ); } else if(building->m_type == Building::TypeSafeArea) { SafeArea *safeArea = (SafeArea *) building; CreateValueControl( LANGUAGEPHRASE("editor_size"), InputField::TypeFloat, &safeArea->m_size, y+=buttonPitch, 1.0f, 0.0f, 1000.0f ); CreateValueControl( LANGUAGEPHRASE("editor_capacity"), InputField::TypeInt, &safeArea->m_entitiesRequired, y+=buttonPitch, 1, 0, 10000 ); DropDownMenu *menu = new DropDownMenu(true); menu->SetShortProperties( LANGUAGEPHRASE("editor_entitytype"), 10, y+=buttonPitch, m_w-20 ); for( int i = 0; i < Entity::NumEntityTypes; ++i) { menu->AddOption( Entity::GetTypeNameTranslated(i), i ); } menu->RegisterInt( &safeArea->m_entityTypeRequired ); RegisterButton( menu ); } else if(building->m_type == Building::TypeTrackStart) { TrackStart *trackStart = (TrackStart *) building; CreateValueControl( LANGUAGEPHRASE("editor_toggledby"), InputField::TypeInt, &trackStart->m_reqBuildingId, y+=buttonPitch, 1.0f, -1.0f, 1000.0f ); } else if(building->m_type == Building::TypeTrackEnd) { TrackEnd *trackEnd = (TrackEnd *) building; CreateValueControl( LANGUAGEPHRASE("editor_toggledby"), InputField::TypeInt, &trackEnd->m_reqBuildingId, y+=buttonPitch, 1.0f, -1.0f, 1000.0f ); } else if(building->m_type == Building::TypePylonStart) { PylonStart *pylonStart = (PylonStart *) building; CreateValueControl( LANGUAGEPHRASE("editor_toggledby"), InputField::TypeInt, &pylonStart->m_reqBuildingId, y+=buttonPitch, 1.0f, -1.0f, 1000.0f ); } else if(building->m_type == Building::TypeResearchItem ) { DropDownMenu *menu = new DropDownMenu(true); menu->SetShortProperties( LANGUAGEPHRASE("editor_research"), 10, y+=buttonPitch, m_w-20 ); for( int i = 0; i < GlobalResearch::NumResearchItems; ++i ) { menu->AddOption( GlobalResearch::GetTypeNameTranslated( i ), i ); } menu->RegisterInt( &((ResearchItem *)building)->m_researchType ); RegisterButton( menu ); CreateValueControl( LANGUAGEPHRASE("editor_level"), InputField::TypeInt, &((ResearchItem *)building)->m_level, y+=buttonPitch, 1, 0, 4 ); } else if( building->m_type == Building::TypeTriffid ) { Triffid *triffid = (Triffid *) building; CreateValueControl( LANGUAGEPHRASE("editor_size"), InputField::TypeFloat, &triffid->m_size, y+=buttonPitch, 0.1f, 0.0f, 50.0f ); CreateValueControl( LANGUAGEPHRASE("editor_pitch"), InputField::TypeFloat, &triffid->m_pitch, y+=buttonPitch, 0.1f, -M_PI, M_PI ); CreateValueControl( LANGUAGEPHRASE("editor_force"), InputField::TypeFloat, &triffid->m_force, y+=buttonPitch, 1.0f, 0.0f, 1000.0f ); CreateValueControl( LANGUAGEPHRASE("editor_variance"), InputField::TypeFloat, &triffid->m_variance, y+=buttonPitch, 0.01f, 0.0f, M_PI ); CreateValueControl( LANGUAGEPHRASE("editor_reload"), InputField::TypeFloat, &triffid->m_reloadTime, y+=buttonPitch, 1.0f, 0.0f, 1000.0f ); for( int i = 0; i < Triffid::NumSpawnTypes; ++i ) { CreateValueControl( Triffid::GetSpawnNameTranslated(i), InputField::TypeChar, &triffid->m_spawn[i], y+=buttonPitch, 1.0f, 0.0f, 1.0f ); } CreateValueControl( LANGUAGEPHRASE("editor_usetrigger"), InputField::TypeChar, &triffid->m_useTrigger, y+=buttonPitch, 1, 0, 1 ); CreateValueControl( LANGUAGEPHRASE("editor_triggerX"), InputField::TypeFloat, &triffid->m_triggerLocation.x, y+=buttonPitch, 1.0f, -10000.0f, 10000.0f ); CreateValueControl( LANGUAGEPHRASE("editor_triggerZ"), InputField::TypeFloat, &triffid->m_triggerLocation.z, y+=buttonPitch, 1.0f, -10000.0f, 10000.0f ); CreateValueControl( LANGUAGEPHRASE("editor_triggerrad"), InputField::TypeFloat, &triffid->m_triggerRadius, y+=buttonPitch, 1.0f, 0.0f, 1000.0f ); } else if( building->m_type == Building::TypeBlueprintRelay ) { BlueprintRelay *relay = (BlueprintRelay *) building; CreateValueControl( LANGUAGEPHRASE("editor_altitude"), InputField::TypeFloat, &relay->m_altitude, y+=buttonPitch, 1.0f, 0.0f, 1000.0f ); } else if( building->m_type == Building::TypeBlueprintConsole ) { BlueprintConsole *console = (BlueprintConsole *) building; CreateValueControl( LANGUAGEPHRASE("editor_segment"), InputField::TypeInt, &console->m_segment, y+=buttonPitch, 1, 0, 3 ); } else if( building->m_type == Building::TypeAISpawnPoint ) { AISpawnPoint *spawn = (AISpawnPoint *) building; DropDownMenu *menu = new DropDownMenu(); menu->SetShortProperties( LANGUAGEPHRASE("editor_entitytype"), 10, y+=buttonPitch, m_w-20 ); for( int i = 0; i < Entity::NumEntityTypes; ++i ) { menu->AddOption( Entity::GetTypeNameTranslated(i), i ); } menu->RegisterInt( &spawn->m_entityType ); RegisterButton(menu); CreateValueControl( LANGUAGEPHRASE("editor_count"), InputField::TypeInt, &spawn->m_count, y+=buttonPitch, 1, 0, 1000 ); CreateValueControl( LANGUAGEPHRASE("editor_period"), InputField::TypeInt, &spawn->m_period, y+=buttonPitch, 1, 0, 1000 ); CreateValueControl( LANGUAGEPHRASE("editor_spawnlimit"), InputField::TypeInt, &spawn->m_spawnLimit, y+=buttonPitch, 1, 0, 1000 ); } else if( building->m_type == Building::TypeSpawnPopulationLock ) { SpawnPopulationLock *lock = (SpawnPopulationLock *) building; CreateValueControl( LANGUAGEPHRASE("editor_searchradius"), InputField::TypeFloat, &lock->m_searchRadius, y+=buttonPitch, 1.0f, 0.0f, 10000.0f ); CreateValueControl( LANGUAGEPHRASE("editor_maxpopulation"), InputField::TypeInt, &lock->m_maxPopulation, y+=buttonPitch, 1, 0, 10000 ); } else if( building->m_type == Building::TypeSpawnLink || building->m_type == Building::TypeSpawnPointMaster || building->m_type == Building::TypeSpawnPoint ) { class ClearLinksButton: public DarwiniaButton { public: int m_buildingId; void MouseUp() { SpawnBuilding *building = (SpawnBuilding *) g_app->m_location->GetBuilding( m_buildingId ); building->ClearLinks(); } }; ClearLinksButton *button = new ClearLinksButton(); button->SetShortProperties( LANGUAGEPHRASE("editor_clearlinks"), 10, y+=buttonPitch, m_w-20 ); button->m_buildingId = building->m_id.GetUniqueId(); RegisterButton( button ); } else if( building->m_type == Building::TypeScriptTrigger ) { ScriptTrigger *trigger = (ScriptTrigger *) building; CreateValueControl( LANGUAGEPHRASE("editor_range"), InputField::TypeFloat, &trigger->m_range, y+=buttonPitch, 0.5f, 0.0f, 1000.0f ); CreateValueControl( LANGUAGEPHRASE("editor_script"), InputField::TypeString, trigger->m_scriptFilename, y+=buttonPitch, 0,0,0 ); DropDownMenu *menu = new DropDownMenu(true); menu->SetShortProperties( LANGUAGEPHRASE("editor_entitytype"), 10, y+=buttonPitch, m_w-20 ); menu->AddOption( LANGUAGEPHRASE("editor_always"), SCRIPTRIGGER_RUNALWAYS ); menu->AddOption( LANGUAGEPHRASE("editor_never"), SCRIPTRIGGER_RUNNEVER ); menu->AddOption( LANGUAGEPHRASE("editor_cameraenter"), SCRIPTRIGGER_RUNCAMENTER ); menu->AddOption( LANGUAGEPHRASE("editor_cameraview"), SCRIPTRIGGER_RUNCAMVIEW ); for( int i = 0; i < Entity::NumEntityTypes; ++i) { menu->AddOption( Entity::GetTypeNameTranslated(i), i ); } menu->RegisterInt( &trigger->m_entityType); RegisterButton( menu ); } else if( building->m_type == Building::TypeStaticShape ) { StaticShape *staticShape = (StaticShape *) building; CreateValueControl( LANGUAGEPHRASE("editor_scale"), InputField::TypeFloat, &staticShape->m_scale, y+=buttonPitch, 0.1f, 0.0f, 100.0f ); CreateValueControl( LANGUAGEPHRASE("editor_shape"), InputField::TypeString, &staticShape->m_shapeName, y+=buttonPitch, 0,0,0 ); } else if( building->m_type == Building::TypeIncubator ) { CreateValueControl( LANGUAGEPHRASE("editor_spirits"), InputField::TypeInt, &((Incubator *) building)->m_numStartingSpirits, y+=buttonPitch, 1, 0, 1000 ); } else if( building->m_type == Building::TypeEscapeRocket ) { EscapeRocket *rocket = (EscapeRocket *) building; CreateValueControl( LANGUAGEPHRASE("editor_fuel"), InputField::TypeFloat, &rocket->m_fuel, y+=buttonPitch, 0.1f, 0.0f, 100.0f ); CreateValueControl( LANGUAGEPHRASE("editor_passengers"), InputField::TypeInt, &rocket->m_passengers, y+=buttonPitch, 1, 0, 100 ); CreateValueControl( LANGUAGEPHRASE("editor_spawnport"), InputField::TypeInt, &rocket->m_spawnBuildingId, y+=buttonPitch, 1, 0, 9999 ); } else if( building->m_type == Building::TypeDynamicHub ) { DynamicHub *hub = (DynamicHub *)building; CreateValueControl( LANGUAGEPHRASE("editor_shape"), InputField::TypeString, &hub->m_shapeName, y+=buttonPitch, 0,0,0 ); CreateValueControl( LANGUAGEPHRASE("editor_requiredscore"), InputField::TypeInt, &hub->m_requiredScore, y+=buttonPitch, 1, 0, 100000 ); CreateValueControl( LANGUAGEPHRASE("editor_minlinks"), InputField::TypeInt, &hub->m_minActiveLinks, y+=buttonPitch, 1, 0, 100 ); } else if( building->m_type == Building::TypeDynamicNode ) { DynamicNode *node = (DynamicNode *)building; CreateValueControl( LANGUAGEPHRASE("editor_shape"), InputField::TypeString, &node->m_shapeName, y+=buttonPitch, 0,0,0 ); CreateValueControl( LANGUAGEPHRASE("editor_pointspersec"), InputField::TypeInt, &node->m_scoreValue, y+=buttonPitch, 1, 0, 1000 ); } else if( building->m_type == Building::TypeFenceSwitch ) { FenceSwitch *fs = (FenceSwitch *)building; CreateValueControl( LANGUAGEPHRASE("editor_switchonce"), InputField::TypeInt, &fs->m_lockable, y+=buttonPitch, 0, 1, 0 ); CreateValueControl( LANGUAGEPHRASE("editor_script"), InputField::TypeString, &fs->m_script, y+=buttonPitch, 0, 0, 0 ); } }