Description:
Add status to Contracts window.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r195:a5622a66fc28 -

@@ -16,6 +16,7
16 // AddComponent
16 // AddComponent
17 AddComponent(contract, new AreaComponent{squares = message.squares});
17 AddComponent(contract, new AreaComponent{squares = message.squares});
18 AddComponent(contract, new NameComponent{DisplayName = message.name});
18 AddComponent(contract, new NameComponent{DisplayName = message.name});
19 AddComponent(contract, new ContractStatusComponent {status = ContractStatus.Proposed});
19
20
20 }
21 }
21 }
22 }
@@ -220,8 +220,10
220 var area = WorldBuilder.CreateEntity();
220 var area = WorldBuilder.CreateEntity();
221 // WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}});
221 // WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}});
222 WorldBuilder.SendMessage(new SpawnContractMessage{squares = new[] {new Vector2(4,4), new Vector2(5,4)},
222 WorldBuilder.SendMessage(new SpawnContractMessage{squares = new[] {new Vector2(4,4), new Vector2(5,4)},
223 name = "Contract"});
223 name = "Northshore Logging"});
224
224
225 WorldBuilder.SendMessage(new SpawnContractMessage{squares = new[] {new Vector2(4,4), new Vector2(5,4)},
226 name = "Aeres Maximalis Ltd."});
225 World = WorldBuilder.Build();
227 World = WorldBuilder.Build();
226
228
227 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
229 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
@@ -39,16 +39,18
39 case Window.Contracts:
39 case Window.Contracts:
40 var contracts = ReadEntities<AreaComponent>();
40 var contracts = ReadEntities<AreaComponent>();
41
41
42 var names = new List<string>();
42 var contract_data = new List<(string, ContractStatus)>();
43
43
44 // var names = contracts.Select(entity => GetComponent<NameComponent>(entity).DisplayName)
44 // var names = contracts.Select(entity => GetComponent<NameComponent>(entity).DisplayName)
45 foreach(var e in contracts)
45 foreach(var e in contracts)
46 {
46 {
47 names.Add(GetComponent<NameComponent>(e).DisplayName);
47 var name = GetComponent<NameComponent>(e).DisplayName;
48 var status = GetComponent<ContractStatusComponent>(e).status;
49 contract_data.Add((name, status));
48
50
49 }
51 }
50
52
51 ContractsWindow.Render(this.font, this.BridgeEngine, names);
53 ContractsWindow.Render(this.font, this.BridgeEngine, contract_data);
52 break;
54 break;
53 default:
55 default:
54 break;
56 break;
@@ -2,6 +2,7
2
2
3 using ImGuiNET;
3 using ImGuiNET;
4
4
5 using isometricparkfna.Components;
5 using isometricparkfna.Engines;
6 using isometricparkfna.Engines;
6 using isometricparkfna.Messages;
7 using isometricparkfna.Messages;
7
8
@@ -11,62 +12,88
11 {
12 {
12 public static class ContractsWindow
13 public static class ContractsWindow
13 {
14 {
15 public static string selected;
14
16
15 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, List<string> contracts )
17 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, List<(string name, ContractStatus status)> contracts)
16 {
18 {
17 bool newShow = true;
19 bool newShow = true;
18 if (newShow)
20 if (newShow)
19 {
21 {
20 ImGui.PushFont(font);
22 ImGui.PushFont(font);
21
23
22 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
24 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
23 ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f);
25 ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f);
24 ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
26 ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
25 ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
27 ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
26 ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f);
28 ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f);
27 ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
29 ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
28 ImGui.PushStyleColor(ImGuiCol.Header, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
30 ImGui.PushStyleColor(ImGuiCol.Header, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
29 ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
31 ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
30 ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
32 ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
31 ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
33 ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
32
34
33 var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
35 var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
34 ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar);
36 ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar);
35 ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar);
37 ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar);
36 ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar);
38 ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar);
37
39
38 ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f));
40 ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f));
39 ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f));
41 ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f));
40
42
41
43
42
44
43 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
45 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
44 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
46 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
45 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
47 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
46 ImGui.Begin("Contracts", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
48 ImGui.Begin("##Contracts", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
47 ImGui.ListBoxHeader("Contracts:");
49 ImGui.ListBoxHeader("Contracts:");
48 foreach (var contract in contracts)
50 foreach (var contract in contracts)
49 {
51 {
50 // ImGui.Text(contract);
52 // ImGui.Text(contract);
51 ImGui.Selectable(contract, false);
53 // ImGui.Selectable(string.Format("{0}\t{1}", contract.name, contract.status.ToString()), false);
52 }
54 if (ImGui.Selectable(contract.name, ContractsWindow.selected == contract.name))
53 ImGui.ListBoxFooter();
55 {
54 if (ImGui.Button("Okay"))
56 ContractsWindow.selected = contract.name;
55 {
57 }
56 newShow = false;
57 }
58
58
59 ImGui.End();
59 ImGui.SameLine();
60 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
60 switch (contract.status)
61 ImGui.PopStyleVar(4);
61 {
62 ImGui.PopStyleColor(12);
62 case ContractStatus.Proposed:
63 ImGui.PopFont();
63 ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.95f, 1f), contract.status.ToString());
64 break;
65 case ContractStatus.Active:
66 case ContractStatus.Accepted:
67 ImGui.TextColored(new Num.Vector4(0.25f, 0.95f, 0.25f, 1f), contract.status.ToString());
68 break;
69
70 default:
71 break;
72 }
73 }
74 ImGui.ListBoxFooter();
75 if (ImGui.Button("Select"))
76 {
77 System.Console.Write(string.Format("{0} selected", ContractsWindow.selected));
78
79
80 }
81 if (ImGui.Button("Okay"))
82 {
83 newShow = false;
64 }
84 }
65
85
66 if (!newShow)
86 ImGui.End();
67 {
87 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
68 engine.messages.Add(new ToggleWindowMessage {Window = Window.Contracts });
88 ImGui.PopStyleVar(4);
69 }
89 ImGui.PopStyleColor(12);
90 ImGui.PopFont();
91 }
92
93 if (!newShow)
94 {
95 engine.messages.Add(new ToggleWindowMessage { Window = Window.Contracts });
96 }
70
97
71 }
98 }
72 }
99 }
You need to be logged in to leave comments. Login now