void BuildingsCreateWindow::Create()
{
	DarwiniaWindow::Create();

	int y = 25;
	int ySpacing = 18;

    DropDownMenu *menu = new DropDownMenu(true);
    menu->SetShortProperties( LANGUAGEPHRASE("editor_buildingtype"), 10, 25, m_w - 20 );
    menu->RegisterInt( &m_buildingType );
    RegisterButton( menu );
    for (int i = Building::TypeInvalid + 1; i < Building::NumBuildingTypes; ++i)
    {
        menu->AddOption( Building::GetTypeNameTranslated(i), i );
    }

    NewBuildingButton *b = new NewBuildingButton();
    b->SetShortProperties( LANGUAGEPHRASE("editor_createbuilding"), 10, 45, m_w - 20 );
    RegisterButton( b );

//	for (int i = Building::TypeInvalid + 1; i < Building::NumBuildingTypes; ++i)
//	{
//	    NewBuildingButton *n = new NewBuildingButton(i);
//        char *name = Building::GetTypeName( i );
//        n->SetShortProperties( name, 10, y, m_w - 20 );
//		RegisterButton( n );
//		y += ySpacing;
//	}
}
void CheatWindow::Create()
{
    DarwiniaWindow::Create();
    
    int y = 25;

    bool show = true;

    if( show )
    {
        KillAllEnemiesButton *killAllEnemies = new KillAllEnemiesButton();
        killAllEnemies->SetShortProperties( "Kill All Enemies", 10, y, m_w - 20, -1, UnicodeString("Kill All Enemies") );
        RegisterButton( killAllEnemies );
	    m_buttonOrder.PutData( killAllEnemies );

        SpawnDarwiniansButton *spawnDarwiniansGreen = new SpawnDarwiniansButton();
        spawnDarwiniansGreen->SetShortProperties( "Spawn Green", 10, y += 20, (m_w - 25)/2, -1, UnicodeString("Spawn Green") );
        spawnDarwiniansGreen->m_teamId = 0;
        RegisterButton( spawnDarwiniansGreen );
	    m_buttonOrder.PutData( spawnDarwiniansGreen );

        SpawnDarwiniansButton *spawnDarwiniansRed = new SpawnDarwiniansButton();
        spawnDarwiniansRed->SetShortProperties( "Spawn Red", spawnDarwiniansGreen->m_x+spawnDarwiniansGreen->m_w+5, y, (m_w - 25)/2,  -1, UnicodeString("Spawn Red") );
        if( g_app->m_location )
        {
            spawnDarwiniansRed->m_teamId = 1;
        }
        RegisterButton( spawnDarwiniansRed );
	    m_buttonOrder.PutData( spawnDarwiniansRed );

        SpawnDarwiniansButton *spawnDarwiniansYellow = new SpawnDarwiniansButton();
        spawnDarwiniansYellow->SetShortProperties( "Spawn Yellow", 10, y += 20, (m_w - 25)/2,  -1, UnicodeString("Spawn Yellow") );
        spawnDarwiniansYellow->m_teamId = 2;
        RegisterButton( spawnDarwiniansYellow );
	    m_buttonOrder.PutData( spawnDarwiniansYellow );

        SpawnDarwiniansButton *spawnDarwiniansblue = new SpawnDarwiniansButton();
        spawnDarwiniansblue->SetShortProperties( "Spawn Blue", spawnDarwiniansGreen->m_x+spawnDarwiniansGreen->m_w+5, y, (m_w - 25)/2,  -1, UnicodeString("Spawn Blue") );
        spawnDarwiniansblue->m_teamId = 3;
        RegisterButton( spawnDarwiniansblue );
	    m_buttonOrder.PutData( spawnDarwiniansblue );

        SpawnDarwiniansButton *spawnDarwiniansmonster = new SpawnDarwiniansButton();
        spawnDarwiniansmonster->SetShortProperties( "Spawn Virus", 10, y += 20, (m_w - 25)/2, -1, UnicodeString("Spawn Virus") );
        if( g_app->m_location )
        {
            spawnDarwiniansmonster->m_teamId = g_app->m_location->GetMonsterTeamId();
        }
        RegisterButton( spawnDarwiniansmonster );
	    m_buttonOrder.PutData( spawnDarwiniansmonster );

        SpawnDarwiniansButton *spawnDarwiniansfuture = new SpawnDarwiniansButton();
        spawnDarwiniansfuture->SetShortProperties( "Spawn Future", spawnDarwiniansGreen->m_x+spawnDarwiniansGreen->m_w+5, y, (m_w - 25)/2, -1, UnicodeString("Spawn Future") );
        if( g_app->m_location )
        {
            spawnDarwiniansfuture->m_teamId = g_app->m_location->GetFuturewinianTeamId();
        }
        RegisterButton( spawnDarwiniansfuture );
	    m_buttonOrder.PutData( spawnDarwiniansfuture );

        SpawnTankButton *spawnTankButton = new SpawnTankButton();
        spawnTankButton->SetShortProperties( "Spawn Armour", 10, y += 20, m_w - 20, -1, UnicodeString("Spawn Armour") );
        RegisterButton( spawnTankButton );
	    m_buttonOrder.PutData( spawnTankButton );

        SpawnViriiButton *spawnVirii = new SpawnViriiButton();
        spawnVirii->SetShortProperties( "Spawn Virii", 10, y += 20, m_w - 20, -1, UnicodeString("Spawn Virii") );
        RegisterButton( spawnVirii );
	    m_buttonOrder.PutData( spawnVirii );

        SpawnSpiritButton *spawnSpirits = new SpawnSpiritButton();
        spawnSpirits->SetShortProperties( "Spawn Spirits", 10, y += 20, m_w - 20, -1, UnicodeString("Spawn Spirits") );
        RegisterButton( spawnSpirits );
	    m_buttonOrder.PutData( spawnSpirits );
        
        AllowArbitraryPlacementButton *allowPlacement = new AllowArbitraryPlacementButton();
        allowPlacement->SetShortProperties( "Allow Arbitrary Placement", 10, y += 20, m_w - 20, -1, UnicodeString("Allow Arbitrary Placement") );
        RegisterButton( allowPlacement );
	    m_buttonOrder.PutData( allowPlacement );
        
        EnableGeneratorAndMineButton *enable = new EnableGeneratorAndMineButton();
        enable->SetShortProperties( "Enable Generator and Mine", 10, y += 20, m_w - 20, -1, UnicodeString("Enable Generator and Mine") );
        RegisterButton( enable );
	    m_buttonOrder.PutData( enable );

        EnableReceiverAndBufferButton *receiver = new EnableReceiverAndBufferButton();
        receiver->SetShortProperties( "Enable Receiver and Buffer", 10, y += 20, m_w - 20, -1, UnicodeString("Enable Receiver and Buffer") );
        RegisterButton( receiver );
	    m_buttonOrder.PutData( receiver );

        OpenAllLocationsButton *openAllLocations = new OpenAllLocationsButton();
        openAllLocations->SetShortProperties( "Open All Locations", 10, y += 20, m_w - 20, -1, UnicodeString("Open All Locations") );
        RegisterButton( openAllLocations );
	    m_buttonOrder.PutData( openAllLocations );

        GiveAllResearchButton *allResearch = new GiveAllResearchButton();
        allResearch->SetShortProperties( "Give all research", 10, y += 20, m_w - 20, -1, UnicodeString("Give all research") );
        RegisterButton( allResearch );
	    m_buttonOrder.PutData( allResearch );

        ClearResourcesButton *clearResources = new ClearResourcesButton();
        clearResources->SetShortProperties( "Clear Resources", 10, y += 20, m_w - 20, -1, UnicodeString("Clear Resources") );
        RegisterButton( clearResources );
	    m_buttonOrder.PutData( clearResources );

        SpawnPortsButton *spawnPorts = new SpawnPortsButton();
        spawnPorts->SetShortProperties( "Spawn Ports", 10, y+=20, m_w - 20,  -1, UnicodeString("Spawn Ports") );
        RegisterButton( spawnPorts );
	    m_buttonOrder.PutData( spawnPorts );

        if( g_app->Multiplayer() )
        {
            CrateCreateButton *ccb = new CrateCreateButton();
            ccb->m_good = true;
            ccb->SetShortProperties( "GoodCrate", 10, y+=20, (m_w / 2) - 20, -1, UnicodeString("GoodCrate") );
            RegisterButton( ccb );
	        m_buttonOrder.PutData( ccb );

            DropDownMenu *crates = new DropDownMenu();
            crates->SetShortProperties( "Crates", m_w / 2, y, (m_w/2) - 10,  -1, UnicodeString("Crates"));
            for( int p = 0; p < Crate::NumCrateRewards; ++p )
            {
                crates->AddOption( Crate::GetName(p), p );
            }
            RegisterButton( crates );
	        m_buttonOrder.PutData( crates );
            crates->RegisterInt( &ccb->m_reward );

        }
        y+=20;
    }
    
    ProfilerCreateButton *profiler = new ProfilerCreateButton();
    profiler->SetShortProperties( "Profiler", 10, y+=20, m_w-20,  -1, UnicodeString("Profiler"));
    RegisterButton( profiler );
	m_buttonOrder.PutData( profiler );
	
#ifdef SOUND_EDITOR
    SoundEditorCreateButton *soundEditor = new SoundEditorCreateButton();
    soundEditor->SetShortProperties( "Sound Editor", 10, y+=20, m_w-20,  -1, UnicodeString("Sound Editor"));
    RegisterButton( soundEditor );
	m_buttonOrder.PutData( soundEditor );

    SoundStatsCreateButton *soundStats = new SoundStatsCreateButton();
    soundStats->SetShortProperties( "Sound Stats", 10, y+=20, m_w-20, -1, UnicodeString("Sound Stats") );
    RegisterButton( soundStats );
	m_buttonOrder.PutData( soundStats );
#endif // SOUND_EDITOR

    NetworkStatsCreateButton *networkStats = new NetworkStatsCreateButton();
    networkStats->SetShortProperties( "Network Stats", 10, y+=20, m_w-20, -1, UnicodeString("Network Stats") );
    RegisterButton( networkStats );
	m_buttonOrder.PutData( networkStats );

	ShowDrSepulvedaFaceButton *faceButton = new ShowDrSepulvedaFaceButton();
    faceButton->SetShortProperties( "Network Stats", 10, y+=20, m_w-20, -1, UnicodeString("Show Dr S Face") );
    RegisterButton( faceButton );
	m_buttonOrder.PutData( faceButton );
}
void PrefsKeybindingsWindow::Create()
{
    DarwiniaWindow::Create();

	int fontSize = GetMenuSize(11);
	int y = GetClientRectY1();
	int border = GetClientRectX1() + GetMenuSize(5);
	int x = m_w * 2 / 3;
	int buttonH = GetMenuSize(20);
	int buttonW = m_w - border * 2 - x;
	int h = buttonH + border;

	if ( 0 == m_controlMethod )
		s_indices = s_gesture_controls;
	else
		s_indices = s_icon_controls;

    ControlMethodDropDownMenu *controlMethod = new ControlMethodDropDownMenu();
    controlMethod->SetShortProperties( LANGUAGEPHRASE("newcontrols_prefsoption"), x, y+=border, buttonW, buttonH );
    controlMethod->AddOption( LANGUAGEPHRASE("newcontrols_prefs_gestures"), 0 );
    controlMethod->AddOption( LANGUAGEPHRASE("newcontrols_prefs_icons"), 1 );
    controlMethod->RegisterInt( &m_controlMethod );
	controlMethod->m_fontSize = GetMenuSize(11);
    RegisterButton( controlMethod );
	m_buttonOrder.PutData( controlMethod );

    InvertedBox *box = new InvertedBox();
	unsigned num_controls = 0;
	while ( s_indices[num_controls] >= 0 ) { num_controls++; }
    box->SetShortProperties( "invert", 10, y+h, m_w - 20, (num_controls * h) + border);
    RegisterButton( box );

    y += border;

    for (unsigned j = 0; j < num_controls; ++j)
	{
		int i = s_indices[ j ];
		ChangeKeybindingButton *but = new ChangeKeybindingButton( i, s_controls[i].instant );
		char const *eventName = LANGUAGEPHRASE( s_controls[i].name );
		but->SetShortProperties(eventName, x, y+=h, buttonW, buttonH);
		but->m_fontSize = GetMenuSize(15);
		but->m_centered = true;
		char const *keyName =  m_bindings[i]->noun.c_str();
		strcpy(but->m_caption, keyName);
		RegisterButton(but);
		m_buttonOrder.PutData( but );
	}

#ifdef TARGET_OS_MACOSX
	DropDownMenu *numMouseButtons = new DropDownMenu();
    numMouseButtons->SetShortProperties( " ", x, y+=h, buttonW, buttonH );
    numMouseButtons->AddOption( "1", 1 );
    numMouseButtons->AddOption( "3", 3 );
    numMouseButtons->RegisterInt( &m_numMouseButtons );
    RegisterButton( numMouseButtons );
	m_buttonOrder.PutData( numMouseButtons );
#endif

	y = m_h - (h+5);

	RestoreDefaultsButton *restore = new RestoreDefaultsButton();
	restore->SetShortProperties(LANGUAGEPHRASE("dialog_restoredefaults"), border, y - h, m_w - border*2, buttonH);
	restore->m_fontSize = fontSize;
	restore->m_centered = true;
	RegisterButton(restore);
	m_buttonOrder.PutData( restore );

	int buttonW2 = m_w / 2 - border * 2;

    CloseButton *cancel = new CloseButton();
    cancel->SetShortProperties( LANGUAGEPHRASE("dialog_close"), border, y, buttonW2, buttonH );
    cancel->m_fontSize = fontSize;
    cancel->m_centered = true;
    RegisterButton( cancel );
	m_buttonOrder.PutData( cancel );

    ApplyKeybindingsButton *apply = new ApplyKeybindingsButton();
    apply->SetShortProperties( LANGUAGEPHRASE("dialog_apply"), m_w - buttonW2 - border, y, buttonW2, buttonH );
    apply->m_fontSize = fontSize;
    apply->m_centered = true;
    RegisterButton( apply );
	m_buttonOrder.PutData( apply );
}
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 );
	}

}
void SoundParameterEditor::Create()
{
    DarwiniaWindow::Create();

    //
    // Parameter type

    DropDownMenu *paramType = new DropDownMenu(false);
    paramType->SetShortProperties( "ParameterType", 10, 30, 150, -1, UnicodeString("ParameterType") );
    for( int i = 0; i < SoundParameter::NumParameterTypes; ++i )
    {
        paramType->AddOption( SoundParameter::GetParameterTypeName(i) );
    }
    paramType->RegisterInt( &m_parameter->m_type );
    RegisterButton( paramType );


    //
    // Link type

    LinkTypeMenu *linkType = new LinkTypeMenu();
    linkType->SetShortProperties( "LinkType", 10, 50, 150, -1, UnicodeString("LinkType") );
    for( int i = 0; i < SoundParameter::NumLinkTypes; ++i )
    {
        linkType->AddOption( SoundParameter::GetLinkName(i) );
    }
    linkType->RegisterInt( &m_parameter->m_link );
    RegisterButton( linkType );


    //
    // Smoothing factor

    CreateValueControl( "SmoothFactor", &m_parameter->m_smooth, 30, 0.05, 0.0, 0.99, NULL, 170, m_w - 180 );


    //
    // Update type

    UpdateTypeMenu *updateType = new UpdateTypeMenu();
    updateType->SetShortProperties( "UpdateType", 170, 50, m_w - 180, -1, UnicodeString("UpdateType") );
    for( int i = 0; i < SoundParameter::NumUpdateTypes; ++i )
    {
        updateType->AddOption( SoundParameter::GetUpdateTypeName(i) );
    }
    updateType->RegisterInt( &m_parameter->m_updateType );
    RegisterButton( updateType );

    
    //
    // Graph 
    
    SoundParameterGraph *graph = new SoundParameterGraph();
    graph->SetShortProperties( "graph", 10, 70, m_w - 20, m_h - 80, UnicodeString("  ") );
	//strcpy(graph->m_name, "graph");
    graph->SetParameter( m_parameter, m_minOutput, m_maxOutput );
    RegisterButton( graph );

//	SoundParameterGraphScaleToggle *scaleToggle = new SoundParameterGraphScaleToggle();
//	scaleToggle->SetShortProperties("Toggle Scale", 10, 50, 150);
//	RegisterButton(scaleToggle);
}