// Startup public override void Startup(ContentManager content) { _UI.Startup(_G.Game, _G.GameInput); // load textures int bundleIndex = _UI.Texture.CreateBundle(); _UI.Texture.Add(bundleIndex, "Textures\\UI_Box", "box"); // load fonts _UI.Font.Add("Fonts\\", "SegoeUI"); // setup common font styles UI.FontStyle fontStyle = new UI.FontStyle("SegoeUI"); fontStyle.AddRenderPass(new UI.FontStyleRenderPass()); _UI.Store_FontStyle.Add("Default", fontStyle); UI.FontStyle fontStyleDS = new UI.FontStyle("SegoeUI"); UI.FontStyleRenderPass renderPassDS = new UI.FontStyleRenderPass(); renderPassDS.ColorOverride = Color.Black; renderPassDS.AlphaMult = 0.5f; renderPassDS.Offset = new Vector3(0.05f, -0.05f, 0.0f); renderPassDS.OffsetProportional = true; fontStyleDS.AddRenderPass(renderPassDS); fontStyleDS.AddRenderPass(new UI.FontStyleRenderPass()); _UI.Store_FontStyle.Add("Default3dDS", fontStyleDS); // setup font icons _UI.Store_FontIcon.Add("A", new UI.FontIcon(_UI.Texture.Get("null"), 0.0f, 0.0f, 1.0f, 1.0f)); _UI.Store_FontIcon.Add("B", new UI.FontIcon(_UI.Texture.Get("null"), 0.0f, 0.0f, 1.0f, 1.0f)); // add initial screens _UI.Screen.AddScreen(new UI.Screen_Background()); _UI.Screen.AddScreen(new UI.Screen_Start()); }
// Startup public override void Startup( ContentManager content ) { _UI.Startup( _G.Game, _G.GameInput ); // load textures int bundleIndex = _UI.Texture.CreateBundle(); _UI.Texture.Add( bundleIndex, "Textures\\UI_Box", "box" ); // load fonts _UI.Font.Add( "Fonts\\", "SegoeUI" ); // setup common font styles UI.FontStyle fontStyle = new UI.FontStyle( "SegoeUI" ); fontStyle.AddRenderPass( new UI.FontStyleRenderPass() ); _UI.Store_FontStyle.Add( "Default", fontStyle ); UI.FontStyle fontStyleDS = new UI.FontStyle( "SegoeUI" ); UI.FontStyleRenderPass renderPassDS = new UI.FontStyleRenderPass(); renderPassDS.ColorOverride = Color.Black; renderPassDS.AlphaMult = 0.5f; renderPassDS.Offset = new Vector3( 0.05f, -0.05f, 0.0f ); renderPassDS.OffsetProportional = true; fontStyleDS.AddRenderPass( renderPassDS ); fontStyleDS.AddRenderPass( new UI.FontStyleRenderPass() ); _UI.Store_FontStyle.Add( "Default3dDS", fontStyleDS ); // setup font icons _UI.Store_FontIcon.Add( "A", new UI.FontIcon( _UI.Texture.Get( "null" ), 0.0f, 0.0f, 1.0f, 1.0f ) ); _UI.Store_FontIcon.Add( "B", new UI.FontIcon( _UI.Texture.Get( "null" ), 0.0f, 0.0f, 1.0f, 1.0f ) ); // add initial screens _UI.Screen.AddScreen( new UI.Screen_Background() ); _UI.Screen.AddScreen( new UI.Screen_Start() ); }
// Copy public FontStyleRenderPass Copy() { FontStyleRenderPass o = new FontStyleRenderPass(); o.ColorOverride = ColorOverride; o.AlphaMult = AlphaMult; o.Offset = Offset; o.OffsetProportional = OffsetProportional; o.TextureIndex = TextureIndex; o.TextureMode = TextureMode; return o; }
// Startup public override void Startup( ContentManager content ) { _UI.Startup( _G.Game, _G.GameInput ); // load textures int bundleIndex = _UI.Texture.CreateBundle(); _UI.Texture.Add( bundleIndex, "Textures\\UI_Box", "box" ); for (int i = 0; i < 4; i++) { _UI.Texture.AddDynamic(bundleIndex, "bag", "Textures\\tex" + i, "BagButtonTex" + i); _UI.Texture.AddDynamic(bundleIndex, "yifu", "Textures\\tex" + i, "ClothButtonTex"+i); _UI.Texture.Add(bundleIndex,"Textures\\tex"+i,"ClothTexture"+i); } //Add Dynamic Texture for Bag Model //_UI.Texture.AddDynamic(bundleIndex, "yifu", "Textures\\tex0", "BagDisplayUnit"); // load fonts _UI.Font.Add( "Fonts\\", "SegoeUI" ); // setup common font styles UI.FontStyle fontStyle = new UI.FontStyle( "SegoeUI" ); fontStyle.AddRenderPass( new UI.FontStyleRenderPass() ); _UI.Store_FontStyle.Add( "Default", fontStyle ); UI.FontStyle fontStyleDS = new UI.FontStyle( "SegoeUI" ); UI.FontStyleRenderPass renderPassDS = new UI.FontStyleRenderPass(); renderPassDS.ColorOverride = Color.Black; renderPassDS.AlphaMult = 0.5f; renderPassDS.Offset = new Vector3( 0.05f, -0.05f, 0.0f ); renderPassDS.OffsetProportional = true; fontStyleDS.AddRenderPass( renderPassDS ); fontStyleDS.AddRenderPass( new UI.FontStyleRenderPass() ); _UI.Store_FontStyle.Add( "Default3dDS", fontStyleDS ); // setup font icons _UI.Store_FontIcon.Add( "A", new UI.FontIcon( _UI.Texture.Get( "null" ), 0.0f, 0.0f, 1.0f, 1.0f ) ); _UI.Store_FontIcon.Add( "B", new UI.FontIcon( _UI.Texture.Get( "null" ), 0.0f, 0.0f, 1.0f, 1.0f ) ); // add initial screens //_UI.Screen.AddScreen( new UI.Screen_Background() ); //_UI.Screen.AddScreen( new UI.Screen_LevelSelect() ); this.SideBars = new UI.SideBar(); _UI.Screen.AddScreen(SideBars); }
// AddRenderPass public void AddRenderPass( FontStyleRenderPass renderPass ) { RenderPasses.Add( renderPass ); }
// Render public unsafe void Render( FontSpriteList list, float height ) { fixed ( FontSprite *pSpriteStart = &list.Sprites[ 0 ] ) { for ( int i = 0; i < RenderPasses.Count; ++i ) { FontStyleRenderPass renderPass = RenderPasses[ i ]; FontSprite *pSprite = ( pSpriteStart + list.RenderStart ); for ( int j = list.RenderStart; j < list.RenderEnd; ++j, ++pSprite ) { bool isIcon = ( pSprite->IconIndex != -1 ); SpriteColors colors; if ( !renderPass.ColorOverride.HasValue ) colors = pSprite->Colors; else { colors = renderPass.ColorOverride.Value; colors.MultA( ref pSprite->Colors ); if ( pSprite->Colors.PreMultipliedAlpha ) colors.ToPremultiplied(); } if ( renderPass.AlphaMult != 1.0f ) colors.MultA( (byte)( renderPass.AlphaMult * 255.0f ) ); // should this be auto-adjusted for 3d? I'm not convinced atm ... Vector3 position = pSprite->Position + ( renderPass.OffsetProportional ? ( renderPass.Offset * height ) : renderPass.Offset ); if ( isIcon ) { FontIcon fontIcon = _UI.Store_FontIcon.Get( pSprite->IconIndex ); _UI.Sprite.AddSprite( list.RenderPass, list.Layer + fontIcon.LayerOffset, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref fontIcon.RenderState ); } else _UI.Sprite.AddSprite( list.RenderPass, list.Layer, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref RenderState ); _UI.Sprite.AddTexture( 0, ref pSprite->Texture ); if ( !isIcon && ( renderPass.TextureIndex != -1 ) ) { Vector2 puv = new Vector2(); Vector2 suv = new Vector2( 1.0f ); switch ( renderPass.TextureMode ) { case E_FontStyleTextureMode.Character: { puv.X = pSprite->Texture.PUV.X; puv.Y = pSprite->Texture.PUV.Y; suv.X = pSprite->Texture.SUV.X; suv.Y = pSprite->Texture.SUV.Y; break; } case E_FontStyleTextureMode.Shift: { puv.X = pSprite->Texture.PUV.X; suv.X = pSprite->Size.X / pSprite->Size.Y; break; } case E_FontStyleTextureMode.PositionShift: { puv.X = pSprite->Texture.PUV.X + ( pSprite->Position.X * 0.5f ); suv.X = pSprite->Size.X / pSprite->Size.Y; break; } } _UI.Sprite.AddTexture( 1, renderPass.TextureIndex, ref puv, ref suv ); } } } } }
// Startup public override void Startup( ContentManager content ) { _UI.Startup( _G.Game, _G.GameInput ); // load textures int bundleIndex = _UI.Texture.CreateBundle(); _UI.Texture.Add( bundleIndex, "Textures\\UI_Box", "box" ); _UI.Texture.Add( bundleIndex, "Textures\\UI_Shine", "shine" ); _UI.Texture.Add( bundleIndex, "Textures\\UI_Buttons", "buttons" ); _UI.Texture.Add( bundleIndex, "Textures\\UI_FontMult", "font_mult" ); _UI.Texture.Add( bundleIndex, "Textures\\UI_DebugMenu", "debug_menu" ); _UI.Texture.Add( bundleIndex, "Textures\\tick", "tick" ); _UI.Texture.Add( bundleIndex, "Textures\\World_1", "world_1" ); _UI.Texture.Add( bundleIndex, "Textures\\World_2", "world_2" ); _UI.Texture.Add( bundleIndex, "Textures\\World_3", "world_3" ); _UI.Texture.Add( bundleIndex, "Textures\\World_4", "world_4" ); _UI.Texture.Add( bundleIndex, "Textures\\MM_NewGame", "mm_newgame" ); _UI.Texture.Add( bundleIndex, "Textures\\MM_LevelSelect", "mm_levelselect" ); _UI.Texture.Add( bundleIndex, "Textures\\MM_Options", "mm_options" ); _UI.Texture.Add( bundleIndex, "Textures\\MM_Quit", "mm_quit" ); _UI.Texture.Add( bundleIndex, "Textures\\CompanyLogo", "company_logo" ); _UI.Texture.Add( bundleIndex, "Textures\\GameLogo", "game_logo" ); // load fonts _UI.Font.Add( "Fonts\\", "Verdana" ); _UI.Font.Add( "Fonts\\", "Impact" ); // everyone has initial control _UI.PrimaryPad = -1; // setup colors _UI.Store_Color.Add( "Blue", 0xff0000ff ); _UI.Store_Color.Add( "Red", 0xffff0000 ); // setup timelines UI.Timeline timelineText = new UI.Timeline( "selected", false, 0.0f, 0.25f, UI.E_TimerType.Stop, UI.E_RestType.Start ); timelineText.AddEffect( new UI.TimelineEffect_ColorLerp( Color.Orange, UI.E_LerpType.SmoothStep ) ); _UI.Store_Timeline.Add( "text_selected_color", timelineText ); UI.Timeline timeline_StartAlpha = new UI.Timeline( "start", false, 0.0f, 0.25f, UI.E_TimerType.Stop, UI.E_RestType.Start ); timeline_StartAlpha.AddEffect( new UI.TimelineEffect_Alpha( -1.0f, 0.0f, UI.E_LerpType.SmoothStep ) ); _UI.Store_Timeline.Add( "text_start_alpha", timeline_StartAlpha ); // setup textures UI.SpriteTexture texture = new UI.SpriteTexture( "buttons", 0.0f, 0.0f, 0.5f, 1.0f ); _UI.Store_Texture.Add( "buttons_half", texture ); // setup font styles UI.FontStyle fontStyle = new UI.FontStyle( "Impact" ); fontStyle.AddRenderPass( new UI.FontStyleRenderPass() ); _UI.Store_FontStyle.Add( "Default", fontStyle ); UI.FontStyle fontStyleDS = new UI.FontStyle( "Impact" ); UI.FontStyleRenderPass renderPassDS = new UI.FontStyleRenderPass(); renderPassDS.ColorOverride = Color.Black; renderPassDS.AlphaMult = 0.5f; renderPassDS.Offset = new Vector3( 0.05f, -0.05f, 0.0f ); renderPassDS.OffsetProportional = true; fontStyleDS.AddRenderPass( renderPassDS ); fontStyleDS.AddRenderPass( new UI.FontStyleRenderPass() ); _UI.Store_FontStyle.Add( "DefaultDS", fontStyleDS ); // setup font effects UI.FontEffect fontEffect = new UI.FontEffect_Scale( 0.0625f, 0.25f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f, UI.E_LerpType.Sin ); _UI.Store_FontEffect.Add( "menu_item_scale", fontEffect ); // setup font icons _UI.Store_FontIcon.Add( "A", new UI.FontIcon( _UI.Texture.Get( "buttons" ), 0.0f, 0.0f, ( 64.0f / 820.0f ), 1.0f ) ); _UI.Store_FontIcon.Add( "B", new UI.FontIcon( _UI.Texture.Get( "buttons" ), ( 63.0f / 820.0f ), 0.0f, ( 64.0f / 820.0f ), 1.0f ) ); _UI.Store_FontIcon.Add( "X", new UI.FontIcon( _UI.Texture.Get( "buttons" ), ( 126.0f / 820.0f ), 0.0f, ( 64.0f / 820.0f ), 1.0f ) ); _UI.Store_FontIcon.Add( "Y", new UI.FontIcon( _UI.Texture.Get( "buttons" ), ( 189.0f / 820.0f ), 0.0f, ( 64.0f / 820.0f ), 1.0f ) ); // setup widgets UI.WidgetText text = new UI.WidgetText(); text.ColorBase = Color.White; text.Align = UI.E_Align.TopCentre; text.Position = new Vector3( 0.0f, 18.0f, 0.0f ); text.Size = new Vector3( 0.0f, 3.0f, 0.0f ); text.Alpha = 0.5f; text.FontStyleName = "Default"; text.AddTimeline( "text_start_alpha" ); text.RenderPass = 1; _UI.Store_Widget.Add( "font_effect_text", text ); // set initial screen PlayState = E_PlayState.TestUI; if ( PlayState == E_PlayState.GameWorld ) { _G.Game.DoLayerUpdate( E_Layer.LevelEditor, false ); _G.Game.DoLayerRender( E_Layer.LevelEditor, false ); _UI.Screen.AddScreen( new UI.HUD() ); } else if ( PlayState == E_PlayState.LevelEditor ) { _G.Game.DoLayerUpdate( E_Layer.GameWorld, false ); _G.Game.DoLayerRender( E_Layer.GameWorld, false ); _UI.Screen.AddScreen( new UI.LevelEditorHUD() ); } else if ( PlayState == E_PlayState.TestUI ) { _G.Game.DoLayerUpdate( E_Layer.GameWorld, false ); _G.Game.DoLayerRender( E_Layer.GameWorld, false ); _G.Game.DoLayerUpdate( E_Layer.LevelEditor, false ); _G.Game.DoLayerRender( E_Layer.LevelEditor, false ); _UI.Screen.AddScreen( new UI.Test() ); } }