Skip to content

Commit 90f566d

Browse files
committed
v0.2.5, fix #33
1 parent 26287e2 commit 90f566d

File tree

4 files changed

+59
-13
lines changed

4 files changed

+59
-13
lines changed

HEROsMod.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public override void Unload()
116116
}
117117
extensionMenuService = null;
118118
miscOptions = null;
119+
prefixEditor = null;
119120
_hotbar = null;
120121
ServiceController = null;
121122
TimeWeatherControlHotbar.Unload();
@@ -371,6 +372,7 @@ public void RegisterPermission(string permissionName, string permissionDisplayNa
371372
}
372373

373374
private MiscOptions miscOptions;
375+
internal PrefixEditor prefixEditor;
374376
private ExtensionMenuService extensionMenuService;
375377

376378
// TODO, is this ok to do on load rather than on enter?
@@ -404,7 +406,8 @@ public static void LoadAddServices()
404406
ServiceController.AddService(new MobSpawner());
405407
ServiceController.AddService(new BuffService());
406408
ServiceController.AddService(new GodModeService());
407-
ServiceController.AddService(new PrefixEditor());
409+
instance.prefixEditor = new PrefixEditor();
410+
ServiceController.AddService(instance.prefixEditor);
408411
// ServiceController.AddService(new InvasionService());
409412
ServiceController.AddService(new Teleporter());
410413
ServiceController.AddService(new RegionService());
@@ -563,6 +566,11 @@ public static void GameLeft()
563566
ServiceController.MyGroupChanged();
564567
}
565568

569+
public override void PreSaveAndQuit()
570+
{
571+
instance.prefixEditor.PreSaveAndQuit();
572+
}
573+
566574
//public static void SaveSettings()
567575
//{
568576
// InventoryManager.Save();

HEROsMod.csproj

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
<Reference Include="System.Runtime.Serialization" />
5757
<Reference Include="System.XML" />
5858
<Reference Include="System.Xml.Linq" />
59+
<Reference Include="Terraria, Version=1.3.5.1, Culture=neutral, processorArchitecture=x86">
60+
<SpecificVersion>False</SpecificVersion>
61+
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Terraria\Terraria.exe</HintPath>
62+
</Reference>
5963
</ItemGroup>
6064
<ItemGroup>
6165
<Compile Include="Commands\AdminInstructionsCommand.cs" />
@@ -146,15 +150,9 @@
146150
<Content Include="build.txt" />
147151
<Content Include="description.txt" />
148152
</ItemGroup>
149-
<ItemGroup>
150-
<ProjectReference Include="..\..\..\Modding\tModLoader\src\tModLoader\Terraria.csproj">
151-
<Project>{3996d5fa-6e59-4fe4-9f2b-40eeef9645d5}</Project>
152-
<Name>Terraria</Name>
153-
</ProjectReference>
154-
</ItemGroup>
155153
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
156154
<PropertyGroup>
157-
<PostBuildEvent>"C:\Program Files (x86)\Steam\steamapps\common\terraria\tModLoaderServerDebug.exe" -build "$(ProjectDir)\" -eac "$(TargetPath)"</PostBuildEvent>
155+
<PostBuildEvent>"C:\Program Files (x86)\Steam\steamapps\common\terraria\tModLoaderServer.exe" -build "$(ProjectDir)\" -eac "$(TargetPath)"</PostBuildEvent>
158156
</PropertyGroup>
159157
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
160158
Other similar extension points exist, see Microsoft.Common.targets.

HEROsModServices/PrefixEditor.cs

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Collections.Generic;
77
using System.Linq;
88
using Terraria;
9+
using Terraria.ModLoader;
910

1011
namespace HEROsMod.HEROsModServices
1112
{
@@ -39,12 +40,21 @@ public override void MyGroupUpdated()
3940
{
4041
this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("PrefixEditor");
4142
//base.MyGroupUpdated();
43+
if (!HasPermissionToUse)
44+
{
45+
_prefixWindow.bClose_onLeftClick(null, null);
46+
}
47+
}
48+
49+
internal void PreSaveAndQuit()
50+
{
51+
_prefixWindow.bClose_onLeftClick(null, null);
4252
}
4353
}
4454

4555
internal class PrefixWindow : UIWindow
4656
{
47-
private Slot itemSlot;
57+
internal Slot itemSlot;
4858
private UIScrollView prefixList;
4959
private int[] prefixes;
5060
private List<Particle> particles;
@@ -89,7 +99,7 @@ public PrefixWindow()
8999
UIImage bClsoe = new UIImage(closeTexture);
90100
bClsoe.X = Width - bClsoe.Width - LargeSpacing;
91101
bClsoe.Y = LargeSpacing;
92-
bClsoe.onLeftClick += bClsoe_onLeftClick;
102+
bClsoe.onLeftClick += bClose_onLeftClick;
93103

94104
AddChild(itemSlot);
95105
AddChild(prefixList);
@@ -126,12 +136,41 @@ public override void Draw(SpriteBatch spriteBatch)
126136
}
127137
}
128138

129-
private void bClsoe_onLeftClick(object sender, EventArgs e)
139+
internal void bClose_onLeftClick(object sender, EventArgs e)
130140
{
131141
this.Visible = false;
142+
ClearOutItemSlots();
143+
}
144+
145+
internal void ClearOutItemSlots()
146+
{
147+
if (!itemSlot.item.IsAir)
148+
{
149+
Item item = itemSlot.item.Clone();
150+
151+
Player player = Main.LocalPlayer;
152+
item.position = player.Center;
153+
Item item2 = player.GetItem(player.whoAmI, item, false, true);
154+
if (item2.stack > 0)
155+
{
156+
int num = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item2.type, item2.stack, false, (int)item.prefix, true, false);
157+
Main.item[num].newAndShiny = false;
158+
if (Main.netMode == 1)
159+
{
160+
NetMessage.SendData(21, -1, -1, null, num, 1f, 0f, 0f, 0, 0, 0);
161+
}
162+
else
163+
{
164+
ErrorLogger.Log("HerosMod: You left an item in the prefix editor with a full inventory and have lost the item: " + item2.Name);
165+
}
166+
167+
}
168+
itemSlot.item.TurnToAir();
169+
itemSlot_ItemChanged(null, null);
170+
}
132171
}
133172

134-
private void itemSlot_ItemChanged(object sender, EventArgs e)
173+
internal void itemSlot_ItemChanged(object sender, EventArgs e)
135174
{
136175
prefixes = new int[83];
137176
for (int i = 0; i < 83; i++)

build.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
author = HERO, jopojelly, Matt Thompson, Everni
2-
version = 0.2.4
2+
version = 0.2.5
3+
versionScheme = ?.?.Fix.Quickfix
34
displayName = HERO's Mod
45
homepage = http://forums.terraria.org/index.php?threads/heros-mod-creative-mode-server-management-and-over-25-tools-1-3-1-1-compatible.44650/
56
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, tmod\*, ignore\*, ZVidBuild\*, Images\Old*, Images\AllIcons.psd, .git\*, LICENSE, .gitignore

0 commit comments

Comments
 (0)