void MouseUp()
    {
		if (m_type == TypeSave)
		{
            //
            // If a MOD hasn't been set, don't allow this to happen
            // as it will try to save into darwinia/data/levels, which is clearly wrong
            // for the end user (but allow it for us)

#ifndef TARGET_DEBUG
            if( !g_app->m_resource->IsModLoaded() )
            {
                EclRegisterWindow( new MessageDialog( LANGUAGEPHRASE( "dialog_savelocationsfail1" ),
                                                      LANGUAGEPHRASE( "dialog_savelocationsfail2" ) ),
                                                      m_parent );
                return;
            }
#endif

            g_app->m_location->m_levelFile->Save();

			return;
		}

		g_app->m_locationEditor->RequestMode(m_type);
    }
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;
//	}
}
示例#3
0
文件: app.cpp 项目: BITINT/DEFCON2
static void ReplaceStringFlagWindowed( char *caption, char flag, bool windowed )
{
	if( windowed )
	{
		LPREPLACESTRINGFLAG( flag, LANGUAGEPHRASE("dialog_windowed"), caption );
	}
	else
	{
		LPREPLACESTRINGFLAG( flag, LANGUAGEPHRASE("dialog_fullscreen"), caption );
	}
}
void LandscapeEditWindow::Create()
{
	DarwiniaWindow::Create();

	int height = 5;
	int pitch = 17;
	int buttonWidth = m_w - 20;

	LandscapeTileButton *gen = new LandscapeTileButton(NULL);
	gen->SetShortProperties(LANGUAGEPHRASE("editor_generate"), 10, height += pitch, m_w - 20);
	RegisterButton(gen);

    NewTileButton *newTile = new NewTileButton();
    newTile->SetShortProperties(LANGUAGEPHRASE("editor_newtile"), 10, height += pitch, m_w - 20);
    RegisterButton(newTile);

    NewFlattenAreaButton *newFlat = new NewFlattenAreaButton();
    newFlat->SetShortProperties(LANGUAGEPHRASE("editor_newflattenarea"), 10, height += pitch, m_w - 20);
    RegisterButton(newFlat);

    height += 8;

    ScaleLandscapeButton *scaleDown = new ScaleLandscapeButton();
    scaleDown->SetShortProperties( LANGUAGEPHRASE("editor_scaledown"), 10, height += pitch, m_w - 20 );
    scaleDown->m_scaleFactor = 0.95f;
    RegisterButton( scaleDown );

    ScaleLandscapeButton *scaleUp = new ScaleLandscapeButton();
    scaleUp->SetShortProperties( LANGUAGEPHRASE("editor_scaleup"), 10, height += pitch, m_w - 20 );
    scaleUp->m_scaleFactor = 1.05f;
    RegisterButton( scaleUp );

    height += 8;

#define FLOAT InputField::TypeFloat
#define INTGR InputField::TypeInt
#define Y height += pitch

	LandscapeDef *landDef = &g_app->m_location->m_levelFile->m_landscape;
    CreateValueControl( LANGUAGEPHRASE("editor_outsideheight"), FLOAT, &landDef->m_outsideHeight,	Y, 1.0f,	-100,	100,	gen );
    CreateValueControl( LANGUAGEPHRASE("editor_cellsize"),		FLOAT, &landDef->m_cellSize,		Y, 1,		1.0f,	100.0f,	gen );
    CreateValueControl( LANGUAGEPHRASE("editor_worldsizex"),	INTGR, &landDef->m_worldSizeX,		Y, 10,		1,		1e6,	gen );
    CreateValueControl( LANGUAGEPHRASE("editor_worldsizez"),    INTGR, &landDef->m_worldSizeZ,		Y, 10,		1,		1e6,	gen );

#undef FLOAT
#undef INTGR
#undef Y

    CreateValueControl( LANGUAGEPHRASE("editor_movebuildings"), InputField::TypeInt, &g_app->m_locationEditor->m_moveBuildingsWithLandscape,
                        height+=pitch, 1, 0, 1 );
}
示例#5
0
void CasualtiesWindow::Render( bool hasFocus )
{
    InterfaceWindow::Render( hasFocus );
    
    g_renderer->SetClip( m_x, m_y+20, m_w, m_h-20 );

    int x = m_x + 10;
    int y = m_y + 30;
    int titleSize = 18;
    int textSize = 13;

    y-= m_scrollbar->m_currentValue;
    
    g_renderer->TextSimple( x, y, White, titleSize, LANGUAGEPHRASE("dialog_casualties_city") );
    g_renderer->TextSimple( x+200, y, White, titleSize, LANGUAGEPHRASE("dialog_casualties_strikes") );
    g_renderer->TextSimple( x+300, y, White, titleSize, LANGUAGEPHRASE("dialog_casualties_deaths") );

    y+=20;

    int numEntries = 0;

    for( int i = 0; i < g_app->GetWorld()->m_cities.Size(); ++i )
    {
        if( g_app->GetWorld()->m_cities.ValidIndex(i) )
        {
            City *city = g_app->GetWorld()->m_cities[i];
            if( city->m_dead > 0 )
            {
                char strikes[64];
                char deaths[64];

                sprintf( strikes, "%d", city->m_numStrikes );
				sprintf( deaths, LANGUAGEPHRASE("dialog_casualties_in_million") );
				char number[32];
				sprintf( number, "%.1f", city->m_dead / 1000000.0f );
				LPREPLACESTRINGFLAG( 'C', number, deaths );

                g_renderer->TextSimple( x, y+=18, White, textSize, LANGUAGEPHRASEADDITIONAL(city->m_name) );
                g_renderer->TextSimple( x+200, y, White, textSize, strikes );
                g_renderer->TextSimple( x+300, y, White, textSize, deaths );

                ++numEntries;
            }
        }
    }

    g_renderer->ResetClip();

    m_scrollbar->SetNumRows( (numEntries+1) * 18 );
}
 void MouseUp()
 {
     if( m_safetyCatch )
     {
         SetCaption(LANGUAGEPHRASE("editor_deletenow"));
         m_safetyCatch = false;
     }
     else
     {
         g_app->m_location->m_levelFile->RemoveBuilding( g_app->m_locationEditor->m_selectionId );
 	    EclRemoveWindow(LANGUAGEPHRASE("editor_buildingid"));
         g_app->m_locationEditor->m_tool = LocationEditor::ToolNone;
         g_app->m_locationEditor->m_selectionId = -1;
     }
 }
示例#7
0
文件: app.cpp 项目: BITINT/DEFCON2
void App::SaveGameName()
{
	// Check m_server to be sure it's a game created by us.
	if( m_server && m_game )
	{
		int serverNameIndex = m_game->GetOptionIndex( "ServerName" );
		if( serverNameIndex != -1 )
		{
			char *newServerName = m_game->GetOption( "ServerName" )->m_currentString;
			if( strcmp( newServerName, LANGUAGEPHRASE("gameoption_New_Game_Server") ) == 0 )
			{
				newServerName = g_languageTable->LookupBasePhrase( "gameoption_New_Game_Server" );
			}

			char *serverName1 = g_preferences->GetString( "ServerName1", "" );
			char *serverName2 = g_preferences->GetString( "ServerName2", "" );
			char *serverName3 = g_preferences->GetString( "ServerName3", "" );
			char *serverName4 = g_preferences->GetString( "ServerName4", "" );

			if( strcmp( serverName1, newServerName ) != 0 )
			{
				g_preferences->SetString( "ServerName5", serverName4 );
				g_preferences->SetString( "ServerName4", serverName3 );
				g_preferences->SetString( "ServerName3", serverName2 );
				g_preferences->SetString( "ServerName2", serverName1 );
				g_preferences->SetString( "ServerName1", newServerName );
			}
		}
	}
}
示例#8
0
void BadKeyWindow::Render( bool _hasFocus )
{
    InterfaceWindow::Render( _hasFocus );


    //
    // Extra message

    float yPos = m_y + 20;
    float size = 14;
    float gap = 17;
    
    if( m_extraMessage[0] != '\x0' )
    {
        MultiLineText wrapped( m_extraMessage, m_w-20, size );

        for( int i = 0; i < wrapped.Size(); ++i )
        {
            char *thisLine = wrapped[i];
            g_renderer->TextCentreSimple( m_x + m_w/2, yPos+=gap, White, size, thisLine );
        }

        yPos += gap*2;
    }


    //
    // DEMO message

    if( m_offerDemo )
    {
        g_renderer->TextCentreSimple( m_x + m_w/2, m_y + m_h - 60, White, size, LANGUAGEPHRASE("dialog_may_play_as_demo_user") );
    }
}
void SafeArea::GetObjectiveCounter(UnicodeString& _dest)
{
    static wchar_t result[256];
	swprintf( result, sizeof(result)/sizeof(wchar_t),
			  L"%ls : %d", LANGUAGEPHRASE("objective_currentcount").m_unicodestring, m_entitiesCounted );
    _dest = UnicodeString( result );
}
示例#10
0
void ConnectingWindow::RenderTimeRemaining( float _fractionDone )
{
    static float s_timeRemaining = 0;
    static float s_timer = 0;

    float timeNow = GetHighResTime();

    if( timeNow > s_timer + 0.5f )
    {
        s_timer = timeNow;
        float timeSoFar = timeNow - m_stageStartTime;
        float timeForOnePercent = timeSoFar/_fractionDone;
        float percentRemaining = 1.0f - _fractionDone;
        s_timeRemaining = percentRemaining * timeForOnePercent;
    }

    if( s_timeRemaining > 0 && s_timeRemaining < 100000 )
    {
        int minutes = int(s_timeRemaining / 60.0f);
        int seconds = s_timeRemaining - minutes * 60;

		char caption[512];
		sprintf( caption, LANGUAGEPHRASE("dialog_state_time_remaining") );
		LPREPLACEINTEGERFLAG( 'M', minutes, caption );
		char number[32];
		sprintf( number, "%02d", seconds );
		LPREPLACESTRINGFLAG( 'S', number, caption );
        g_renderer->TextCentreSimple( m_x + m_w/2, m_y + m_h - 60, White, 14, caption );
    }
}
char *Generator::GetObjectiveCounter()
{
    static char result[256];
    sprintf( result, "%s : %d Gq/s", LANGUAGEPHRASE("objective_output"),
                                     int(m_throughput*10) );
    return result;
}
void ColourWindow::Create()
{
    DarwiniaWindow::Create();

    int y = 25;
    int h = 18;

    unsigned char *r = ((unsigned char *) m_value)+0;
    unsigned char *g = ((unsigned char *) m_value)+1;
    unsigned char *b = ((unsigned char *) m_value)+2;
    unsigned char *a = ((unsigned char *) m_value)+3;

    CreateValueControl( LANGUAGEPHRASE("editor_red"),   InputField::TypeChar, r, y,    1, 0, 255, m_callback, -1, m_w - 80 );
    CreateValueControl( LANGUAGEPHRASE("editor_green"), InputField::TypeChar, g, y+=h, 1, 0, 255, m_callback, -1, m_w - 80 );
    CreateValueControl( LANGUAGEPHRASE("editor_blue"),  InputField::TypeChar, b, y+=h, 1, 0, 255, m_callback, -1, m_w - 80 );
    CreateValueControl( LANGUAGEPHRASE("editor_alpha"), InputField::TypeChar, a, y+=h, 1, 0, 255, m_callback, -1, m_w - 80 );
}
void ColourWidget::MouseUp()
{
    ColourWindow *cw = new ColourWindow( LANGUAGEPHRASE("editor_coloureditor") );
    cw->SetSize( 200, 100 );
    cw->SetValue( m_value );
    cw->SetCallback( m_callback );
    EclRegisterWindow( cw, m_parent );
}
void Tutorial::Render()
{
    if( !g_app->m_editing && 
        g_app->m_location && 
        !g_app->m_renderer->m_renderingPoster &&
        ( (int) g_gameTime % 2 == 0 ) &&
        m_chapter > 0 )
    {
        g_gameFont.BeginText2D();
        g_gameFont.SetRenderOutline(true);        
        glColor4f(1.0,1.0,1.0,0.0);
        g_gameFont.DrawText2DCentre( g_app->m_renderer->ScreenW()/2.0, 15, 15, LANGUAGEPHRASE("dialog_skiptutorial") );
        g_gameFont.SetRenderOutline(false);
        glColor4f(1.0,1.0,1.0,1.0);
        g_gameFont.DrawText2DCentre( g_app->m_renderer->ScreenW()/2.0, 15, 15, LANGUAGEPHRASE("dialog_skiptutorial") );
        g_gameFont.EndText2D();    
    }
}
	void MouseUp()
	{
		if (stricmp(m_name, LANGUAGEPHRASE("editor_generate")) == 0)
		{
			LandscapeDef *def = &g_app->m_location->m_levelFile->m_landscape;
			g_app->m_location->m_landscape.Init(def);
		}
		else if (stricmp(m_name, LANGUAGEPHRASE("editor_randomise")) == 0)
		{
			m_def->m_randomSeed = (int)(GetHighResTime() * 1000.0f);
			InputField *randomSeed = (InputField *)m_parent->GetButton(LANGUAGEPHRASE("editor_seed"));
			if (randomSeed)
			{
				randomSeed->Refresh();
			}
			LandscapeDef *def = &g_app->m_location->m_levelFile->m_landscape;
			g_app->m_location->m_landscape.Init(def);
		}
        else if( stricmp(m_name, LANGUAGEPHRASE("editor_delete")) == 0 )
        {
            int tileId = ((LandscapeTileEditWindow *) m_parent)->m_tileId;
            g_app->m_location->m_landscape.DeleteTile( tileId );
            EclRemoveWindow( m_parent->m_name );
        }
        else if( stricmp(m_name, LANGUAGEPHRASE("editor_clone")) == 0 )
        {
            Vector3 rayStart;
	        Vector3 rayDir;
	        g_app->m_camera->GetClickRay(g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2, &rayStart, &rayDir);
            Vector3 _pos;
            g_app->m_location->m_landscape.RayHit( rayStart, rayDir, &_pos );

            LandscapeDef *landscapeDef = &(g_app->m_location->m_levelFile->m_landscape);
    	    LandscapeTile *tile = new LandscapeTile();
    	    g_app->m_location->m_levelFile->m_landscape.m_tiles.PutDataAtEnd(tile);
            tile->m_size = m_def->m_size;
            tile->m_posX = _pos.x - tile->m_size/2;
            tile->m_posY = m_def->m_posY;
            tile->m_posZ = _pos.z - tile->m_size/2;
            tile->m_fractalDimension = m_def->m_fractalDimension;
            tile->m_heightScale = m_def->m_heightScale;
            tile->m_desiredHeight = m_def->m_desiredHeight;
            tile->m_randomSeed = m_def->m_randomSeed;
            tile->m_lowlandSmoothingFactor = m_def->m_lowlandSmoothingFactor;
            tile->m_generationMethod = m_def->m_generationMethod;

		    LandscapeDef *def = &g_app->m_location->m_levelFile->m_landscape;
            g_app->m_location->m_landscape.Init(def);

        }
        else if( stricmp(m_name, LANGUAGEPHRASE("editor_guidegrid")) == 0 )
        {
            int tileId = ((LandscapeTileEditWindow *) m_parent)->m_tileId;
            LandscapeGuideGridWindow *guide = new LandscapeGuideGridWindow(LANGUAGEPHRASE("editor_guidegrid"), tileId );
            guide->SetSize( 300, 300 );
            guide->SetPosition( m_parent->m_x + m_parent->m_w + 10, m_parent->m_y );
            EclRegisterWindow( guide, m_parent );
        }
	}
示例#16
0
char *Tutorial::GetCurrentObjective()
{
    if( m_chapters.ValidIndex(m_currentChapter) )
    {
        TutorialChapter *chapter = m_chapters[m_currentChapter];
        char *phrase = LANGUAGEPHRASE( chapter->m_objective );
        return phrase;
    }

    return NULL;
}
// *** Advance
void UserInput::Advance()
{
    START_PROFILE(g_app->m_profiler, "Advance UserInput");

	g_inputManager->Advance();

	if (m_removeTopLevelMenu)
	{
		EclWindow *win = EclGetWindow(LANGUAGEPHRASE("dialog_toolsmenu"));
		if (win)
		{
			EclRemoveWindow(win->m_name);
		}
		m_removeTopLevelMenu = false;
	}

	AdvanceMenus();

    bool modsEnabled = g_prefsManager->GetInt( "ModSystemEnabled", 0 ) != 0;


    if( g_inputManager->controlEvent( ControlGamePause ) )	g_app->m_clientToServer->RequestPause();

//    if (g_keyDeltas[KEY_F2]) DebugKeyBindings::DebugCameraButton();
#ifdef LOCATION_EDITOR
    if( modsEnabled )
    {
        if ( g_inputManager->controlEvent( ControlToggleEditor ) ) DebugKeyBindings::EditorButton();
    }
#endif
//
#ifdef CHEATMENU_ENABLED
    if( g_inputManager->controlEvent( ControlToggleCheatMenu ) ) DebugKeyBindings::CheatButton();
#endif

//
//    if (g_keyDeltas[KEY_F5]) DebugKeyBindings::FPSButton();
//#ifdef PROFILER_ENABLED
//	if (g_keyDeltas[KEY_F10]) DebugKeyBindings::ProfileButton();
//#endif // PROFILER_ENABLED


#ifdef SOUND_EDITOR
    if( modsEnabled )
    {
//        if (g_keyDeltas[KEY_F7]) DebugKeyBindings::SoundStatsButton();
//        if (g_keyDeltas[KEY_F11]) DebugKeyBindings::SoundEditorButton();
//        if (g_keyDeltas[KEY_F9]) DebugKeyBindings::SoundProfileButton();
    }
#endif // SOUND_EDITOR

    END_PROFILE(g_app->m_profiler, "Advance UserInput");
}
示例#18
0
文件: silo.cpp 项目: cahocachi/DEFCON
Silo::Silo()
:   WorldObject(),
    m_numNukesLaunched(0)
{
    SetType( TypeSilo );

    strcpy( bmpImageFilename, "graphics/sam.bmp" );

    m_radarRange = 20;
    m_selectable = true;

    m_currentState = 1;
    m_life = 25;

    m_nukeSupply = 10;

    AddState( LANGUAGEPHRASE("state_silonuke"), 120, 120, 10, Fixed::MAX, true, 10, 1 );         
    AddState( LANGUAGEPHRASE("state_airdefense"), 340, 20, 10, 30, true );

    InitialiseTimers();
}
StartSequence::StartSequence()
{
    m_startTime = GetHighResTime();

    float screenRatio = (float) g_app->m_renderer->ScreenH() / (float) g_app->m_renderer->ScreenW();
    int screenH = 800 * screenRatio;

    float x = 150;
    float y = screenH*4/5.0f;
    float size = 10.0f;

    RegisterCaption( LANGUAGEPHRASE( "intro_1" ),  x, y, size, 3, 15 );
    RegisterCaption( LANGUAGEPHRASE( "intro_2" ),  x, y+15, 20, 8, 15 );
	RegisterCaption( LANGUAGEPHRASE( "intro_3" ),  x, y+40, size, 30, 45 );
    RegisterCaption( LANGUAGEPHRASE( "intro_4" ),  x, y+50, size, 42, 45 );
    RegisterCaption( LANGUAGEPHRASE( "intro_5" ),  x, y, size, 54, 65 );
    RegisterCaption( LANGUAGEPHRASE( "intro_6" ),  x, y, size, 66, 74 );
    RegisterCaption( LANGUAGEPHRASE( "intro_7" ),  x, y+15, size, 72, 74 );
    RegisterCaption( LANGUAGEPHRASE( "intro_8" ),  x, y, size, 74, 90 );
    RegisterCaption( LANGUAGEPHRASE( "intro_9" ),  x, y+15, 15, 82, 90 );
    RegisterCaption( LANGUAGEPHRASE( "intro_10" ), x, y+30, 15, 86, 90 );
}
示例#20
0
文件: app.cpp 项目: BITINT/DEFCON2
static void ReplaceStringFlagColorBit( char *caption, char flag, int colourDepth )
{
	if( colourDepth == 16 )
	{
		LPREPLACESTRINGFLAG( flag, LANGUAGEPHRASE("dialog_colourdepth_16"), caption );
	}
	else if( colourDepth == 24 )
	{
		LPREPLACESTRINGFLAG( flag, LANGUAGEPHRASE("dialog_colourdepth_24"), caption );
	}
	else if( colourDepth == 32 )
	{
		LPREPLACESTRINGFLAG( flag, LANGUAGEPHRASE("dialog_colourdepth_32"), caption );
	}
	else
	{
		char numberBit[128];
		sprintf( numberBit, LANGUAGEPHRASE("dialog_colourdepth_X") );
		LPREPLACEINTEGERFLAG( 'C', colourDepth, numberBit );
		LPREPLACESTRINGFLAG( flag, numberBit, caption );
	}
}
void MessageDialog::Create()
{
	int const buttonWidth = GetMenuSize(40);
	int const buttonHeight = GetMenuSize(18);
	OKButton *button = new OKButton(this);

    char *caption = "Close";
    if( g_app->m_langTable ) caption = LANGUAGEPHRASE("dialog_close");

    button->SetShortProperties( caption, (m_w - buttonWidth)/2, m_h - GetMenuSize(30), buttonWidth, buttonHeight );
    button->m_fontSize = GetMenuSize(11);
    RegisterButton( button );
}
    void MouseUp()
    {
        if( stricmp( m_name, LANGUAGEPHRASE("editor_generate") ) == 0 )
        {
            LandscapeGuideGridWindow *parent = (LandscapeGuideGridWindow *) m_parent;
	        parent->m_tileDef->GuideGridSetPower(parent->m_guideGridPower);
			LandscapeDef *def = &g_app->m_location->m_levelFile->m_landscape;
            g_app->m_location->m_landscape.Init(def);

            parent->Remove();
            parent->Create();
        }
    }
示例#23
0
文件: nuke.cpp 项目: cahocachi/DEFCON
Nuke::Nuke()
:   MovingObject(),
    m_prevDistanceToTarget( Fixed::MAX ),
    m_newLongitude(0),
    m_newLatitude(0),
    m_targetLocked(false)
{
    SetType( TypeNuke );

    strcpy( bmpImageFilename, "graphics/nuke.bmp" );

    m_radarRange = 0;
    m_speed = Fixed::Hundredths(20);
    m_selectable = true;
    m_maxHistorySize = -1;
    m_range = Fixed::MAX;
    m_turnRate = Fixed::Hundredths(1);
    m_movementType = MovementTypeAir;

    AddState( LANGUAGEPHRASE("state_ontarget"), 0, 0, 0, Fixed::MAX, false );
    AddState( LANGUAGEPHRASE("state_disarm"), 100, 0, 0, 0, false );
}
void LandscapeFlattenAreaEditWindow::Create()
{
	DarwiniaWindow::Create();

	m_areaDef = g_app->m_location->m_levelFile->m_landscape.m_flattenAreas.GetData(m_areaId);

	int height = 5;
	int pitch = 17;
	int buttonWidth = m_w - 20;

	LandscapeTileButton *gen = new LandscapeTileButton(NULL);
	gen->SetShortProperties(LANGUAGEPHRASE("editor_generate"), 10, height += pitch, m_w - 20);
	RegisterButton(gen);

    CreateValueControl( LANGUAGEPHRASE("editor_size"), InputField::TypeFloat, &m_areaDef->m_size, height += pitch, 1, 0, 1000, gen );
    CreateValueControl( LANGUAGEPHRASE("editor_height"), InputField::TypeFloat, &m_areaDef->m_centre.y, height += pitch, 1, -1000, 1000, gen );

	LandscapeFlattenAreaDeleteButton *del = new LandscapeFlattenAreaDeleteButton(m_areaId);
	del->SetShortProperties(LANGUAGEPHRASE("editor_delete"), 10, height += pitch, buttonWidth);
	RegisterButton(del);


}
void LandscapeGuideGridWindow::Create()
{
	m_tileDef = g_app->m_location->m_levelFile->m_landscape.m_tiles.GetData(m_tileId);
    m_guideGridPower = m_tileDef->GuideGridGetPower();

    int gridW = m_w - 80;
    int gridH = m_h - 80;

    int biggerSize = min( gridW, gridH );
    if( m_guideGridPower > 0 )
    {
        m_pixelSizePerSample = biggerSize / m_tileDef->m_guideGrid->GetNumColumns();
    }
    else
    {
        m_pixelSizePerSample = 0;
    }

    GuideGridButton *generate = new GuideGridButton();
    generate->SetShortProperties( LANGUAGEPHRASE("editor_generate"), 10, 25, 75 );
    RegisterButton( generate );

    CreateValueControl( LANGUAGEPHRASE("editor_resolution"), InputField::TypeInt, &m_guideGridPower,	25, 1, 0, 5, generate, 100, 150  );
    CreateValueControl( LANGUAGEPHRASE("editor_toolsize"), InputField::TypeFloat, &m_toolSize,			45, 1, 1.0f, 40.0f, NULL, 100, 150 );


    //
    // Create guide grid and paint controls

    GuideGrid *guideGrid = new GuideGrid();
    guideGrid->SetProperties( LANGUAGEPHRASE("editor_guidegrid"), 10, 70, gridW, gridH );
    RegisterButton( guideGrid );

    int controlsX = gridW + 15;
    int controlsY = 70;
    int controlsW = 60;
    int controlsH = 17;

    GuideGridTool *freehand = new GuideGridTool( GuideGridToolFreehand );
    freehand->SetShortProperties( LANGUAGEPHRASE("editor_freehand"), controlsX, controlsY, controlsW );
    RegisterButton( freehand );

    GuideGridTool *flatten = new GuideGridTool( GuideGridToolFlatten );
    flatten->SetShortProperties( LANGUAGEPHRASE("editor_flatten"), controlsX, controlsY += controlsH, controlsW );
    RegisterButton( flatten );

    GuideGridTool *binary = new GuideGridTool( GuideGridToolBinary );
    binary->SetShortProperties( LANGUAGEPHRASE("editor_binary"), controlsX, controlsY += controlsH, controlsW );
    RegisterButton( binary );

    DarwiniaWindow::Create();
}
示例#26
0
void CeaseFireWindow::Render( bool hasFocus )
{
    InterfaceWindow::Render( hasFocus );
    char msg[1024];
    char *helpMessage = NULL;

    if( g_app->GetWorld()->GetMyTeam()->m_ceaseFire[m_teamId] )
    {
        strcpy( msg, LANGUAGEPHRASE("dialog_declarewar"));
        LPREPLACESTRINGFLAG('T', g_app->GetWorld()->GetTeam( m_teamId )->GetTeamName(), msg );
        helpMessage = LANGUAGEPHRASE("tooltip_ceasefire_disable" );
    }
    else
    {
        strcpy( msg, LANGUAGEPHRASE("dialog_ceasefire"));
        LPREPLACESTRINGFLAG('T', g_app->GetWorld()->GetTeam( m_teamId )->GetTeamName(), msg );
        helpMessage = LANGUAGEPHRASE("tooltip_ceasefire_enable" );
    }
    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+25, White, 17, msg );


    //
    // Render tooltip

    float xPos = m_x + 30;
    float yPos = m_y + 40;
    float w = m_w - 60;

    MultiLineText wrapped( helpMessage, w, 11 );

    for( int i = 0; i < wrapped.Size(); ++i )
    {
        char *thisString = wrapped[i];
        g_renderer->TextSimple( xPos, yPos+=13, White, 11, thisString );
    }
}
void Entity::GetTypeNameTranslated ( int _troopType, UnicodeString &_dest )
{
    char *typeName = GetTypeName( _troopType );

    char stringId[256];
    sprintf( stringId, "entityname_%s", typeName );

    if( ISLANGUAGEPHRASE( stringId ) )
    {
        _dest = LANGUAGEPHRASE( stringId );
    }
    else
    {
        _dest = UnicodeString(typeName);
    }
}
char *Building::GetTypeNameTranslated( int _type )
{
    char *typeName = GetTypeName(_type);

    char stringId[256];
    sprintf( stringId, "buildingname_%s", typeName );

    if( ISLANGUAGEPHRASE( stringId ) )
    {
        return LANGUAGEPHRASE( stringId );
    }
    else
    {
        return typeName;
    }
}
示例#29
0
文件: game.cpp 项目: cahocachi/DEFCON
char* GameOption::TranslateValue( char *_value )
{
	char optionName[256];
	snprintf( optionName, sizeof(optionName), "gameoption_%s", _value );
	optionName[ sizeof(optionName) - 1 ] = '\0';
	for( char *cur = optionName; *cur; cur++ )
	{
		if( *cur == ' ' )
		{
			*cur = '_';
		}
	}
	if( g_languageTable->DoesTranslationExist( optionName ) || g_languageTable->DoesPhraseExist( optionName ) )
	{
		return LANGUAGEPHRASE(optionName);
	}
	return _value;
}
void ControlHelpSystem::SetCondIcon( int _cond )
{
	const TextIndicator &ti = m_conditionIconMap[_cond];

	float alpha = 1.0f;

	if (ti.m_minTime != 0.0f && ti.m_maxTime != 0.0f) {
		if (ti.m_timeUsed < ti.m_minTime)
			alpha = 1.0f;
		else
			alpha = (ti.m_maxTime - ti.m_timeUsed ) / (ti.m_maxTime - ti.m_minTime);

		if (alpha < 0.0f)
			return;
	}

	m_icons[ti.m_icon]->Set(ti.m_text, LANGUAGEPHRASE( ti.m_langPhrase ), alpha);
}