Description:
Various UI improvements.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r291:6a7d5e8510b1 -

@@ -10,7 +10,8
10 [Sends(typeof(ToggleWindowMessage),
10 [Sends(typeof(ToggleWindowMessage),
11 typeof(ToggleWindowTypeMessage),
11 typeof(ToggleWindowTypeMessage),
12 typeof(ChangeContractStatusMessage),
12 typeof(ChangeContractStatusMessage),
13 typeof(SelectMessage))]
13 typeof(SelectMessage),
14 typeof(JumpCameraMessage))]
14 [Reads(typeof(VisibilityComponent),
15 [Reads(typeof(VisibilityComponent),
15 typeof(WindowTypeComponent)
16 typeof(WindowTypeComponent)
16 //, typeof(SelectedComponent)
17 //, typeof(SelectedComponent)
@@ -23,6 +24,7
23 public List<ToggleWindowTypeMessage> typeMessages;
24 public List<ToggleWindowTypeMessage> typeMessages;
24 public List<ChangeContractStatusMessage> contractStatusMessages;
25 public List<ChangeContractStatusMessage> contractStatusMessages;
25 public List<SelectMessage> selectedMessages;
26 public List<SelectMessage> selectedMessages;
27 public List<JumpCameraMessage> jumpCameraMessages;
26
28
27 bool showBudget {get;}
29 bool showBudget {get;}
28 bool showForest {get;}
30 bool showForest {get;}
@@ -39,6 +41,7
39 this.typeMessages = new List<ToggleWindowTypeMessage>();
41 this.typeMessages = new List<ToggleWindowTypeMessage>();
40 this.contractStatusMessages = new List<ChangeContractStatusMessage>();
42 this.contractStatusMessages = new List<ChangeContractStatusMessage>();
41 this.selectedMessages = new List<SelectMessage>();
43 this.selectedMessages = new List<SelectMessage>();
44 this.jumpCameraMessages = new List<JumpCameraMessage>();
42 this.windowStatuses = new Dictionary<Window, bool>();
45 this.windowStatuses = new Dictionary<Window, bool>();
43 //Prepopulate:
46 //Prepopulate:
44 foreach(var type in System.Enum.GetValues(typeof(Window)))
47 foreach(var type in System.Enum.GetValues(typeof(Window)))
@@ -66,6 +69,10
66 SendMessage(message);
69 SendMessage(message);
67 // SetComponent<SelectedComponent>(message.Entity, new SelectedComponent { selected = true});
70 // SetComponent<SelectedComponent>(message.Entity, new SelectedComponent { selected = true});
68 }
71 }
72 foreach(var message in this.jumpCameraMessages)
73 {
74 SendMessage(message);
75 }
69
76
70
77
71 foreach(var entity in ReadEntities<WindowTypeComponent>())
78 foreach(var entity in ReadEntities<WindowTypeComponent>())
@@ -79,6 +86,7
79 this.typeMessages.Clear();
86 this.typeMessages.Clear();
80 this.contractStatusMessages.Clear();
87 this.contractStatusMessages.Clear();
81 this.selectedMessages.Clear();
88 this.selectedMessages.Clear();
89 this.jumpCameraMessages.Clear();
82 }
90 }
83 }
91 }
84 }
92 }
@@ -76,7 +76,6
76 if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C))
76 if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C))
77 {
77 {
78 SendMessage(new JumpCameraMessage {Movement = Vector2.Zero });
78 SendMessage(new JumpCameraMessage {Movement = Vector2.Zero });
79
80 }
79 }
81 #endregion camera_movement_keys
80 #endregion camera_movement_keys
82 #region gamerate_keys
81 #region gamerate_keys
@@ -168,11 +167,6
168 System.Console.WriteLine("Quitting");
167 System.Console.WriteLine("Quitting");
169 Environment.Exit(0);
168 Environment.Exit(0);
170 }
169 }
171 if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C))
172 {
173 // this.camera.Jump(Vector2.Zero);
174
175 }
176 #endregion misc_keys
170 #endregion misc_keys
177 #region mouse_movement
171 #region mouse_movement
178
172
@@ -555,12 +555,9
555
555
556 for (int y = 0; y < this.squaresDown; y++)
556 for (int y = 0; y < this.squaresDown; y++)
557 {
557 {
558
559 for (int x = 0; x < this.squaresAcross; x++)
558 for (int x = 0; x < this.squaresAcross; x++)
560 {
559 {
561
562 int screenx = (x - y) * Tile.TileSpriteWidth / 2;
560 int screenx = (x - y) * Tile.TileSpriteWidth / 2;
563
564 int screeny = (x + y) * Tile.TileSpriteHeight / 2;
561 int screeny = (x + y) * Tile.TileSpriteHeight / 2;
565
562
566 if (this.cull(x, y))
563 if (this.cull(x, y))
@@ -28,7 +28,7
28 this.BridgeEngine = engine;
28 this.BridgeEngine = engine;
29 }
29 }
30
30
31 private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index)
31 private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)
32 getContractDetails(Entity entity) {
32 getContractDetails(Entity entity) {
33
33
34 var name = GetComponent<NameAndDescriptionComponent>(entity).DisplayName;
34 var name = GetComponent<NameAndDescriptionComponent>(entity).DisplayName;
@@ -38,6 +38,8
38 var image_index = GetComponent<ImageComponent>(entity).ImageIndex;
38 var image_index = GetComponent<ImageComponent>(entity).ImageIndex;
39 var description = "";
39 var description = "";
40
40
41 var square = GetComponent<AreaComponent>(entity).squares[0];
42
41
43
42 if (HasComponent<RelatedOrganizationComponent>(entity))
44 if (HasComponent<RelatedOrganizationComponent>(entity))
43 {
45 {
@@ -49,7 +51,7
49 image_index = GetComponent<ImageComponent>(related_organization).ImageIndex;
51 image_index = GetComponent<ImageComponent>(related_organization).ImageIndex;
50 }
52 }
51
53
52 return (entity, name, description, status, amount, tree_delta, image_index);
54 return (entity, name, description, status, amount, tree_delta, image_index, square);
53
55
54 }
56 }
55
57
@@ -67,7 +69,7
67 case Window.Contracts:
69 case Window.Contracts:
68 var contracts = ReadEntities<AreaComponent>();
70 var contracts = ReadEntities<AreaComponent>();
69
71
70 var contract_data = new List<(Entity, string, string, ContractStatus, decimal, string, int)>();
72 var contract_data = new List<(Entity, string, string, ContractStatus, decimal, string, int, Vector2)>();
71
73
72 foreach(var e in contracts)
74 foreach(var e in contracts)
73 {
75 {
@@ -84,7 +86,7
84 var area = GetComponent<AreaComponent>(entity).squares;
86 var area = GetComponent<AreaComponent>(entity).squares;
85 var area_size = GetComponent<AreaComponent>(entity).squares.Length;
87 var area_size = GetComponent<AreaComponent>(entity).squares.Length;
86
88
87 ContractWindow.Render(this.font, this.italicFont, this.BridgeEngine, entity, data.name, data.description, data.status, data.amount, data.delta_trees, area_size, data.image_index);
89 ContractWindow.Render(this.font, this.italicFont, this.BridgeEngine, entity, data.name, data.description, data.status, data.amount, data.delta_trees, area_size, data.image_index, data.square);
88
90
89 break;
91 break;
90
92
@@ -8,6 +8,7
8 using isometricparkfna.Components;
8 using isometricparkfna.Components;
9 using isometricparkfna.Engines;
9 using isometricparkfna.Engines;
10 using isometricparkfna.Messages;
10 using isometricparkfna.Messages;
11 using Microsoft.Xna.Framework;
11
12
12 using Num = System.Numerics;
13 using Num = System.Numerics;
13
14
@@ -23,6 +24,8
23
24
24 private static bool show = false;
25 private static bool show = false;
25
26
27 private static Dictionary<string, bool> hadFocus = new Dictionary<string, bool>();
28
26 public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImageMap map)
29 public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImageMap map)
27 {
30 {
28 ContractWindow.map = map;
31 ContractWindow.map = map;
@@ -31,7 +34,7
31 ContractWindow._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
34 ContractWindow._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
32 }
35 }
33
36
34 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int area_size, int imageIndex)
37 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int area_size, int imageIndex, Vector2 square)
35
38
36 {
39 {
37 bool newShow = true;
40 bool newShow = true;
@@ -43,10 +46,33
43 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
46 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
44 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
47 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
45 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
48 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
46 ImGui.SetNextWindowSize(new Num.Vector2(320, 360));
49 ImGui.SetNextWindowSize(new Num.Vector2(320, 420));
47 ImGui.Begin(string.Format("Contract {0} ## {1}", name, entity.ID), ref newShow,
50
51 var title = string.Format("Contract {0} ## {1}", name, entity.ID);
52
53 if (ContractWindow.hadFocus.ContainsKey(title) &&
54 ContractWindow.hadFocus[title])
55 {
56 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
57 }
58
59 ImGui.Begin(name, ref newShow,
48 ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
60 ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
49
61
62 if (ContractWindow.hadFocus.ContainsKey(title) &&
63 ContractWindow.hadFocus[title])
64 {
65 ImGui.PopStyleColor();
66 }
67 if(ContractWindow.hadFocus.ContainsKey(title))
68 {
69 ContractWindow.hadFocus[title] = ImGui.IsWindowFocused();
70 }
71 else
72 {
73 ContractWindow.hadFocus.Add(title, ImGui.IsWindowFocused());
74 }
75
50 ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(imageIndex), map.GetSourceUVEnd(imageIndex), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used
76 ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(imageIndex), map.GetSourceUVEnd(imageIndex), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used
51
77
52 ImGui.PushFont(italicFont);
78 ImGui.PushFont(italicFont);
@@ -117,10 +143,23
117
143
118 ContractStatusButtons(engine, entity, status);
144 ContractStatusButtons(engine, entity, status);
119
145
146 ImGui.Separator();
147
120 if (ImGui.Button("Okay"))
148 if (ImGui.Button("Okay"))
121 {
149 {
122 newShow = false;
150 newShow = false;
123 }
151 }
152 ImGui.SameLine();
153 if (ImGui.Button("Jump To"))
154 {
155 int adjustedx = (int)square.X;
156 int adjustedy = (int)square.Y;
157
158 int screenx = (adjustedx - adjustedy) * Tile.TileSpriteWidth / 2;
159 int screeny = (adjustedx + adjustedy) * Tile.TileSpriteHeight / 2;
160
161 engine.jumpCameraMessages.Add(new JumpCameraMessage {Movement = new Vector2(screenx, screeny)});
162 }
124 // Logging.Trace("Almost done.");
163 // Logging.Trace("Almost done.");
125
164
126 ImGui.End();
165 ImGui.End();
@@ -8,6 +8,7
8 using isometricparkfna.Engines;
8 using isometricparkfna.Engines;
9 using isometricparkfna.Messages;
9 using isometricparkfna.Messages;
10
10
11 using Microsoft.Xna.Framework;
11 using Num = System.Numerics;
12 using Num = System.Numerics;
12
13
13 using Encompass;
14 using Encompass;
@@ -19,11 +20,11
19 public static bool show_all;
20 public static bool show_all;
20 public static bool had_focus = false;
21 public static bool had_focus = false;
21
22
22 private static (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index) selected;
23 private static (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square) selected;
23
24
24
25
25 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine,
26 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine,
26 List<(Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index)> contracts)
27 List<(Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)> contracts)
27 {
28 {
28 bool newShow = true;
29 bool newShow = true;
29
30
@@ -60,6 +60,8
60 public static class NewsWindow
60 public static class NewsWindow
61 {
61 {
62
62
63 public static bool had_focus = false;
64
63 public static void Render(bool show, ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
65 public static void Render(bool show, ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
64 {
66 {
65 bool newShow = show;
67 bool newShow = show;
@@ -68,35 +70,33
68 ImGui.PushFont(font);
70 ImGui.PushFont(font);
69
71
70 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
72 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
71 ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f);
72 ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
73 ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
74 ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f);
75 ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
76 ImGui.PushStyleColor(ImGuiCol.Header, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
77 ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
78 ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
79 ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
80
73
81 ImGui.PushStyleColor(ImGuiCol.TitleBg, StyleSet.title_bar);
74 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
82 ImGui.PushStyleColor(ImGuiCol.TitleBgActive, StyleSet.title_bar);
75 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
83 ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, StyleSet.title_bar);
84
85 ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f));
86 ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f));
87
76
88
77
78 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
89
79
90 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
80 if(NewsWindow.had_focus)
91 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
81 {
92 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
82 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
83 }
93 ImGui.Begin("NEWS", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
84 ImGui.Begin("NEWS", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
94
85
86 if (NewsWindow.had_focus)
87 {
88 ImGui.PopStyleColor();
89 }
90 NewsWindow.had_focus = ImGui.IsWindowFocused();
91
95 var content = sim.latestNewsItems;
92 var content = sim.latestNewsItems;
96
93
97
94
98 if (ImGui.BeginTabBar("Sources", 0)) {
95 if (ImGui.BeginTabBar("Sources", 0)) {
96
97
99 if (ImGui.BeginTabItem("Wire")) {
98 if (ImGui.BeginTabItem("Wire")) {
99
100 foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) ).Take(3)) {
100 foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) ).Take(3)) {
101 if (ImGui.TreeNode(story.hed)) {
101 if (ImGui.TreeNode(story.hed)) {
102 ImGui.TextWrapped(story.contents);
102 ImGui.TextWrapped(story.contents);
@@ -136,8 +136,9
136
136
137 ImGui.End();
137 ImGui.End();
138 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
138 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
139 ImGui.PopStyleVar(4);
139
140 ImGui.PopStyleColor(12);
140 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
141 StyleSet.popColorSet(StyleSet.defaultWindowColors);
141 ImGui.PopFont();
142 ImGui.PopFont();
142 }
143 }
143
144
@@ -35,6 +35,11
35 {ImGuiCol.SliderGrab, darkgrey},
35 {ImGuiCol.SliderGrab, darkgrey},
36 {ImGuiCol.SliderGrabActive, darkgrey},
36 {ImGuiCol.SliderGrabActive, darkgrey},
37
37
38
39 {ImGuiCol.Tab, darkgrey},
40 {ImGuiCol.TabHovered, darkgrey},
41 {ImGuiCol.TabActive, selected},
42
38 {ImGuiCol.CheckMark, black},
43 {ImGuiCol.CheckMark, black},
39
44
40 {ImGuiCol.TitleBg, title_bar},
45 {ImGuiCol.TitleBg, title_bar},
You need to be logged in to leave comments. Login now