• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

Revisão3186e09446691bfc12f4b9a4bc350620cf232fa3 (tree)
Hora2019-11-18 08:28:10
Autormelchior <melchior@user...>
Commitermelchior

Mensagem de Log

W.I.P. #9 Fixes and start on GUI dialog

Mudança Sumário

Diff

--- a/AccessControls/AccessControlMod.cs
+++ b/AccessControls/AccessControlMod.cs
@@ -389,6 +389,7 @@ namespace FirstMachineAge
389389 {
390390 newLockACN.LockStyle = LockKinds.Combination;
391391 newLockACN.CombinationCode = theLock.CombinationCode(itemSlot);
392+ newLockACN.PermittedPlayers = new List<AccessEntry>( );
392393 newLockACN.Tier = theLock.LockTier;
393394
394395 if (newLockACN.CombinationCode == null)
--- a/AccessControls/AccessControls_Internals.cs
+++ b/AccessControls/AccessControls_Internals.cs
@@ -563,8 +563,9 @@ namespace FirstMachineAge
563563 }
564564 }
565565
566- //################### Key holding status changes ########################
566+ //################### Key holding status changes ########################
567567 if (playerLostKeyIDs_byPlayerUID.Count > 0 || playerGainKeyIDs_byPlayerUID.Count > 0) {
568+
568569 Stack<string> playerKeyChanges = new Stack<string>( playerGainKeyIDs_byPlayerUID.Keys.Union(playerLostKeyIDs_byPlayerUID.Keys));
569570
570571 while (playerKeyChanges.Count > 0) {
@@ -573,6 +574,12 @@ namespace FirstMachineAge
573574 IServerPlayer tgtPlayer = ServerAPI.World.PlayerByUid(pid) as IServerPlayer;
574575
575576 Mod.Logger.VerboseDebug("Player {0} held key(s) changed ~ re-evaluating ACNs", tgtPlayer.PlayerName);
577+
578+ string lostKeys = string.Empty;
579+ string gainedKeys = string.Empty;
580+ if (playerLostKeyIDs_byPlayerUID.ContainsKey(pid)) lostKeys = String.Join(",", playerLostKeyIDs_byPlayerUID[pid]);
581+ if (playerGainKeyIDs_byPlayerUID.ContainsKey(pid)) gainedKeys = String.Join(",", playerGainKeyIDs_byPlayerUID[pid]);
582+ Mod.Logger.VerboseDebug("Player {0} Gains [{1}] Loss [{2}] ", tgtPlayer.PlayerName, gainedKeys,lostKeys);
576583 //Extract ACN from Key's stored position data...
577584
578585 var ACNs_comboKeys = new List<KeyValuePair<BlockPos, AccessControlNode>>( );
@@ -582,17 +589,19 @@ namespace FirstMachineAge
582589 if (playerGainKeyIDs_byPlayerUID.ContainsKey(pid)) ACNs_comboKeys = ACNs_comboKeys.Concat(GetACNs_byKeyID(playerGainKeyIDs_byPlayerUID[pid])).ToList();
583590
584591 if ( ACNs_comboKeys.Count > 0) {
585- var keyCount = playerKeyIDs_byPlayerUID.ContainsKey(pid) ? playerKeyIDs_byPlayerUID [pid].Count: 0;
592+ var keyCount = playerKeyIDs_byPlayerUID.ContainsKey(pid) ? playerKeyIDs_byPlayerUID[pid].Count: 0;
586593 Mod.Logger.VerboseDebug("Player {0} - {1} key(s) updates for {2} ACNs", tgtPlayer.PlayerName, keyCount ,ACNs_comboKeys.Count);
587594 SendClientACNMultiUpdates(tgtPlayer, ACNs_comboKeys);
588595
589- //Done set - cleanup;
590- if (playerGainKeyIDs_byPlayerUID.ContainsKey(pid)) playerGainKeyIDs_byPlayerUID[pid].Clear( );
591- if (playerLostKeyIDs_byPlayerUID.ContainsKey(pid)) playerLostKeyIDs_byPlayerUID[pid].Clear( );
596+ //Done set - cleanup for player;
597+ if (playerGainKeyIDs_byPlayerUID.ContainsKey(pid)) playerGainKeyIDs_byPlayerUID[pid].Clear();
598+ if (playerLostKeyIDs_byPlayerUID.ContainsKey(pid)) playerLostKeyIDs_byPlayerUID[pid].Clear();
592599 }
593600
594601 }
595-
602+ //Cleanup, all players
603+ playerGainKeyIDs_byPlayerUID.Clear( );
604+ playerLostKeyIDs_byPlayerUID.Clear( );
596605 }
597606
598607 //########################### Persist & SAVE-COMMIT Altered ACNs ! #########################
@@ -715,7 +724,7 @@ namespace FirstMachineAge
715724 if (controlNode.OwnerPlayerUID == forPlayer.PlayerUID) return false;
716725
717726 //In same faction?
718- if (controlNode.PermittedPlayers != null & controlNode.PermittedPlayers.Count > 0) {
727+ if (controlNode.PermittedPlayers != null && controlNode.PermittedPlayers.Count > 0) {
719728
720729 foreach (var perp in controlNode.PermittedPlayers) {
721730 if (perp.PlayerUID == forPlayer.PlayerUID) {
--- a/AccessControls/GUIs/GuiDialog_ComboLock.cs
+++ b/AccessControls/GUIs/GuiDialog_ComboLock.cs
@@ -1,6 +1,7 @@
11 using System;
22
33 using Vintagestory.API.Client;
4+using Vintagestory.API.MathTools;
45
56 namespace FirstMachineAge
67 {
@@ -10,10 +11,12 @@ namespace FirstMachineAge
1011 private AccessControlsMod ACM;
1112
1213
13- public GuiDialog_ComboLock(ICoreClientAPI capi) : base(capi)
14+ public GuiDialog_ComboLock(ICoreClientAPI capi, uint tier, BlockPos acnPosition) : base(capi)
1415 {
1516 ClientAPI = capi;
1617 ACM = ClientAPI.World.Api.ModLoader.GetModSystem<AccessControlsMod>( );
18+
19+ ComposeElements( );//?
1720 }
1821
1922 public override string ToggleKeyCombinationCode {
@@ -22,6 +25,27 @@ namespace FirstMachineAge
2225 }
2326 }
2427
28+ public override void OnRenderGUI(float deltaTime)
29+ {
30+ SingleComposer = base.SingleComposer;
31+
32+
33+ base.OnRenderGUI(deltaTime);
34+ }
35+
36+
37+ public override void OnGuiOpened( )
38+ {
39+ //Reset fields to zero - set # of boxes by tier.
40+ }
41+
42+ private void ComposeElements( )
43+ {
44+
45+
46+ }
47+
48+
2549
2650 //On 'Try' button click event -> send packet on channel
2751 }
--- a/AccessControls/GroupLocksCmd.cs
+++ b/AccessControls/GroupLocksCmd.cs
@@ -17,7 +17,7 @@ namespace FirstMachineAge
1717 this.Description = "Change lock permissions and assigend groupIDs.";
1818 //this.handler += LocksmithParser;
1919 this.Syntax = "grant [group/player] [player-name/group-name] / revoke [group/player] [player-name/group-name]";
20- //this.RequiredPrivilege = "grouplocks";
20+ this.RequiredPrivilege = "grouplocks";
2121
2222 }
2323 }
--- a/AccessControls/LocksmithCmd.cs
+++ b/AccessControls/LocksmithCmd.cs
@@ -1,4 +1,5 @@
11 using System;
2+using System.Text;
23
34 using Vintagestory.API.Common;
45 using Vintagestory.API.Config;
@@ -20,15 +21,14 @@ namespace FirstMachineAge
2021 this.Command = "locksmith";
2122 this.Description = "ALTER LOCKS: Remove or Change keys and combos.";
2223 this.handler += LocksmithParser;
23- this.Syntax = "remove / change / downgrade / info ";
24+ this.Syntax = "nodes / keys / remove / info ";
2425 this.RequiredPrivilege = "locksmith";
2526
26- if (_coreAPI.Side.IsServer( ))
27- {
28- this.ServerAPI = _coreAPI;
29- this.Logger = this.ServerAPI.World.Logger;
30- AccessControlsMod = ServerAPI.World.Api.ModLoader.GetModSystem<AccessControlsMod>( );
31- }
27+ if (_coreAPI.Side.IsServer( )) {
28+ this.ServerAPI = _coreAPI;
29+ this.Logger = this.ServerAPI.World.Logger;
30+ AccessControlsMod = ServerAPI.World.Api.ModLoader.GetModSystem<AccessControlsMod>( );
31+ }
3232
3333 }
3434
@@ -61,6 +61,13 @@ namespace FirstMachineAge
6161 RemoveLock(targetPos, player);
6262 break;
6363
64+ case "info":
65+ if (player.CurrentBlockSelection == null) return;
66+ targetPos = player.CurrentBlockSelection.Position.Copy( );
67+
68+ PrintLockInfo(targetPos, player);
69+ break;
70+
6471 case "destroy":
6572
6673 break;
@@ -91,53 +98,100 @@ namespace FirstMachineAge
9198 if (actualThing.HasBehavior<BlockBehaviorComplexLockable>( )) {
9299 var acn = AccessControlsMod.RetrieveACN(targetPos);
93100
94- if (acn != null)
95- {
96- if (acn.LockStyle != LockKinds.None) {
97- AccessControlsMod.RemoveLock(targetPos, player);
98- player.SendMessage(GlobalConstants.CurrentChatGroup, "OK, Lock Removed !", EnumChatType.CommandSuccess);
99- }
100- else { player.SendMessage(GlobalConstants.CurrentChatGroup, "ACN in Default 'None' state. (No lock)", EnumChatType.CommandError); }
101- }
102- else {player.SendMessage(GlobalConstants.CurrentChatGroup, "NO ACN (or lock...) there!", EnumChatType.CommandError); }
101+ if (acn != null) {
102+ if (acn.LockStyle != LockKinds.None) {
103+ AccessControlsMod.RemoveLock(targetPos, player);
104+ player.SendMessage(GlobalConstants.CurrentChatGroup, "OK, Lock Removed !", EnumChatType.CommandSuccess);
105+ }
106+ else { player.SendMessage(GlobalConstants.CurrentChatGroup, "ACN in Default 'None' state. (No lock)", EnumChatType.CommandError); }
107+ }
108+ else { player.SendMessage(GlobalConstants.CurrentChatGroup, "NO ACN (or lock...) there!", EnumChatType.CommandError); }
103109 }
104110 else { player.SendMessage(GlobalConstants.CurrentChatGroup, "Thing selected can't be lockable anyways...", EnumChatType.CommandError); }
105111 }
106112 else {
107- player.SendMessage(GlobalConstants.CurrentChatGroup, "Invalid location selected", EnumChatType.CommandError);
113+ player.SendMessage(GlobalConstants.CurrentChatGroup, "Invalid location selected", EnumChatType.CommandError);
108114 }
109115
110116 }
111117
112- private void PrintNodes(IServerPlayer player, int groupId, CmdArgs args )
118+ private void PrintNodes(IServerPlayer player, int groupId, CmdArgs args)
113119 {
114120 if (args.Length > 0) {
115121 var chunkPos = args.PopVec3i(null);
116122 }
117123 else {
118- BlockPos location = player.Entity.ServerPos.AsBlockPos;
124+ BlockPos location = player.Entity.ServerPos.AsBlockPos;
119125 Vec3i chunkPos = ServerAPI.World.BlockAccessor.ToChunkPos(location);
120126
121127 var acn_List = AccessControlsMod.RetrieveACNs_ByChunk(chunkPos);
122128
123129 foreach (var acn in acn_List) {
124130 string name = ServerAPI.World.PlayerByUid(acn.Value.OwnerPlayerUID).PlayerName;
125- player.SendMessage(GlobalConstants.InfoLogChatGroup, $"Node@{acn.Key}:{acn.Value.LockStyle} own:{name} '{acn.Value.NameOfLock}'\n", EnumChatType.CommandSuccess);
131+ player.SendMessage(GlobalConstants.InfoLogChatGroup, $"Node@{acn.Key}:{acn.Value.LockStyle} own:{name} '{acn.Value.NameOfLock}'\n", EnumChatType.CommandSuccess);
126132 }
127133
128134 }
129135 }
130136
131- private void PrintKeys(IServerPlayer player, int groupId, CmdArgs args )
137+ private void PrintKeys(IServerPlayer player, int groupId, CmdArgs args)
132138 {
133- var key_List = AccessControlsMod.RetrieveKnownKeys( );
139+ var key_List = AccessControlsMod.RetrieveKnownKeys( );
134140
135141 foreach (var acn in key_List) {
136- string name = ServerAPI.World.PlayerByUid(acn.Value.Value.OwnerPlayerUID).PlayerName;
137- player.SendMessage(GlobalConstants.InfoLogChatGroup, $"Key#{acn.Key} @{acn.Value.Key} {acn.Value.Value.LockStyle} own:{name} '{acn.Value.Value.NameOfLock}'\n", EnumChatType.CommandSuccess);
142+ string name = ServerAPI.World.PlayerByUid(acn.Value.Value.OwnerPlayerUID).PlayerName;
143+ player.SendMessage(GlobalConstants.InfoLogChatGroup, $"Key#{acn.Key} @{acn.Value.Key} {acn.Value.Value.LockStyle} own:{name} '{acn.Value.Value.NameOfLock}'\n", EnumChatType.CommandSuccess);
138144 }
139145 }
140146
141147
148+ private void PrintLockInfo(BlockPos targetPos, IServerPlayer player)
149+ {
150+ if (ServerAPI.World.BlockAccessor.IsValidPos(targetPos)) {
151+ var actualThing = ServerAPI.World.BlockAccessor.GetBlock(targetPos);
152+ if (actualThing.HasBehavior<BlockBehaviorComplexLockable>( )) {
153+ AccessControlNode acn = AccessControlsMod.RetrieveACN(targetPos);
154+
155+ if (acn != null && acn.LockStyle != LockKinds.None) {
156+ string name = ServerAPI.World.PlayerByUid(acn.OwnerPlayerUID).PlayerName;
157+ StringBuilder lockData = new StringBuilder( );
158+
159+ lockData.AppendFormat($"Pos@{targetPos}:{acn.LockStyle} owner:{name} '{acn.NameOfLock}' Tier:{acn.Tier}");
160+
161+ switch (acn.LockStyle) {
162+
163+ case LockKinds.Classic:
164+ lockData.Append(" <Classic lock> ");
165+ break;
166+
167+ case LockKinds.Combination:
168+ if (acn.CombinationCode != null) { lockData.AppendFormat(" Combo# {0}", String.Join("-", acn.CombinationCode)); }
169+ else {
170+ lockData.Append(" Combo unset!");
171+ }
172+ break;
173+
174+ case LockKinds.Key:
175+ if (acn.KeyID.HasValue) { lockData.AppendFormat(" KeyID# {0}", acn.KeyID.HasValue); }
176+ else {
177+ lockData.Append(" KeyID# UNSET?!");
178+ }
179+ break;
180+
181+ default:
182+ break;
183+ }
184+
185+ player.SendMessage(GlobalConstants.CurrentChatGroup, lockData.ToString( ), EnumChatType.CommandSuccess);
186+ }
187+
188+ }
189+ else { player.SendMessage(GlobalConstants.CurrentChatGroup, "Thing selected can't be lockable anyways...", EnumChatType.CommandError); }
190+ }
191+
192+ }
193+
194+
195+
142196 }
143197 }
--- a/AccessControls/behaviors/BlockBehaviorComplexLockable.cs
+++ b/AccessControls/behaviors/BlockBehaviorComplexLockable.cs
@@ -162,9 +162,9 @@ namespace FirstMachineAge
162162 {
163163 //Popup GUI window;
164164
165-
165+ var tier = acm.LockTier(blockPos, byPlayer );
166166
167- GuiDialog_ComboLock comboGUI = new GuiDialog_ComboLock(clientAPI );
167+ GuiDialog_ComboLock comboGUI = new GuiDialog_ComboLock(clientAPI,tier,blockPos );
168168 comboGUI.TryOpen( );
169169 }
170170 }