Skip to content

Commit 97b3231

Browse files
committed
Crafting
1 parent 7c572b0 commit 97b3231

21 files changed

+869
-47
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ Client/Client.csproj
5555
/Client/obj
5656
/AutoPatcherAdmin/obj
5757

58+
/Build

AutoPatcherAdmin/AutoPatcherAdmin.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<DebugSymbols>true</DebugSymbols>
2020
<DebugType>full</DebugType>
2121
<Optimize>false</Optimize>
22-
<OutputPath>..\..\Server Tools\AutoPatcherAdmin\</OutputPath>
22+
<OutputPath>..\Build\Server Tools\AutoPatcherAdmin\</OutputPath>
2323
<DefineConstants>DEBUG;TRACE</DefineConstants>
2424
<ErrorReport>prompt</ErrorReport>
2525
<WarningLevel>4</WarningLevel>

Client/Client.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<DebugSymbols>true</DebugSymbols>
4343
<DebugType>full</DebugType>
4444
<Optimize>false</Optimize>
45-
<OutputPath>..\..\Client\</OutputPath>
45+
<OutputPath>..\..\Mir 2 SQL\Build\Client\</OutputPath>
4646
<DefineConstants>DEBUG;TRACE</DefineConstants>
4747
<ErrorReport>prompt</ErrorReport>
4848
<WarningLevel>1</WarningLevel>

Client/MirControls/MirImageControl.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,19 @@ protected internal override void DrawControl()
155155

156156
if (DrawImage && Library != null)
157157
{
158-
if (GrayScale) DXManager.SetGrayscale(1F, Color.White);
158+
bool oldGray = DXManager.GrayScale;
159+
160+
if (GrayScale)
161+
{
162+
DXManager.SetGrayscale(true);
163+
}
159164

160165
if (Blending)
161166
Library.DrawBlend(Index, DisplayLocation, ForeColour, false, BlendingRate);
162167
else
163168
Library.Draw(Index, DisplayLocation, ForeColour, false, Opacity);
164169

165-
166-
if (GrayScale) DXManager.SetNormal(1F, Color.White);
170+
if (GrayScale) DXManager.SetGrayscale(oldGray);
167171
}
168172
}
169173

Client/MirControls/MirItemCell.cs

+53-7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ public UserItem Item
5050
}
5151
}
5252

53+
public UserItem ShadowItem
54+
{
55+
get
56+
{
57+
if (GridType == MirGridType.Craft && _itemSlot >= 0 && _itemSlot < ItemArray.Length)
58+
return CraftDialog.ShadowItems[_itemSlot];
59+
60+
return null;
61+
}
62+
}
63+
5364
public UserItem[] ItemArray
5465
{
5566
get
@@ -84,6 +95,8 @@ public UserItem[] ItemArray
8495
return MailComposeParcelDialog.Items;
8596
case MirGridType.Refine:
8697
return GameScene.Refine;
98+
case MirGridType.Craft:
99+
return CraftDialog.IngredientSlots;
87100

88101
default:
89102
throw new NotImplementedException();
@@ -94,7 +107,7 @@ public UserItem[] ItemArray
94107

95108
public override bool Border
96109
{
97-
get { return (GameScene.SelectedCell == this || MouseControl == this || Locked) && GridType != MirGridType.DropPanel; }
110+
get { return (GameScene.SelectedCell == this || MouseControl == this || Locked) && GridType != MirGridType.DropPanel && (GridType != MirGridType.Craft); }
98111
}
99112

100113
private bool _locked;
@@ -239,7 +252,7 @@ public override void OnMouseDoubleClick(MouseEventArgs e)
239252
{
240253
if (Locked) return;
241254

242-
if (GameScene.PickedUpGold || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant) return;
255+
if (GameScene.PickedUpGold || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant || GridType == MirGridType.Craft) return;
243256

244257
base.OnMouseClick(e);
245258

@@ -281,7 +294,7 @@ private void BuyItem()
281294

282295
public void UseItem()
283296
{
284-
if (Locked || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant || GridType == MirGridType.GuildStorage) return;
297+
if (Locked || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant || GridType == MirGridType.GuildStorage || GridType == MirGridType.Craft) return;
285298

286299
if (MapObject.User.Fishing) return;
287300
if (MapObject.User.RidingMount && Item.Info.Type != ItemType.Scroll && Item.Info.Type != ItemType.Potion && Item.Info.Type != ItemType.Torch) return;
@@ -658,7 +671,7 @@ public void RemoveItem()
658671

659672
private void MoveItem()
660673
{
661-
if (GridType == MirGridType.BuyBack || GridType == MirGridType.DropPanel || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant) return;
674+
if (GridType == MirGridType.BuyBack || GridType == MirGridType.DropPanel || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant || GridType == MirGridType.Craft) return;
662675

663676
if (GameScene.SelectedCell != null)
664677
{
@@ -1918,6 +1931,21 @@ protected internal override void DrawControl()
19181931
Library.Draw(image, DisplayLocation.Add(offSet), Color.DimGray, UseOffSet, 0.8F);
19191932
}
19201933
}
1934+
else if (ShadowItem != null)
1935+
{
1936+
CreateDisposeLabel();
1937+
1938+
if (Library != null)
1939+
{
1940+
ushort image = ShadowItem.Info.Image;
1941+
1942+
Size imgSize = Library.GetTrueSize(image);
1943+
1944+
Point offSet = new Point((Size.Width - imgSize.Width) / 2, (Size.Height - imgSize.Height) / 2);
1945+
1946+
Library.Draw(image, DisplayLocation.Add(offSet), Color.DimGray, UseOffSet, 0.8F);
1947+
}
1948+
}
19211949
else
19221950
DisposeCountLabel();
19231951
}
@@ -1928,7 +1956,12 @@ protected override void OnMouseEnter()
19281956
if (GridType == MirGridType.Inspect)
19291957
GameScene.Scene.CreateItemLabel(Item, true);
19301958
else
1931-
GameScene.Scene.CreateItemLabel(Item);
1959+
{
1960+
if (Item != null)
1961+
GameScene.Scene.CreateItemLabel(Item);
1962+
else if (ShadowItem != null)
1963+
GameScene.Scene.CreateItemLabel(ShadowItem);
1964+
}
19321965
}
19331966
protected override void OnMouseLeave()
19341967
{
@@ -1939,7 +1972,10 @@ protected override void OnMouseLeave()
19391972

19401973
private void CreateDisposeLabel()
19411974
{
1942-
if (Item.Info.StackSize <= 1)
1975+
if (Item == null && ShadowItem == null)
1976+
return;
1977+
1978+
if (Item != null && ShadowItem == null && Item.Info.StackSize <= 1)
19431979
{
19441980
DisposeCountLabel();
19451981
return;
@@ -1957,7 +1993,17 @@ private void CreateDisposeLabel()
19571993
};
19581994
}
19591995

1960-
CountLabel.Text = Item.Count.ToString("###0");
1996+
if (ShadowItem != null)
1997+
{
1998+
CountLabel.ForeColour = (Item == null || ShadowItem.Count > Item.Count) ? Color.Red : Color.LimeGreen;
1999+
2000+
CountLabel.Text = string.Format("{0}/{1}", Item == null ? 0 : Item.Count, ShadowItem.Count);
2001+
}
2002+
else
2003+
{
2004+
CountLabel.Text = Item.Count.ToString("###0");
2005+
}
2006+
19612007
CountLabel.Location = new Point(Size.Width - CountLabel.Size.Width, Size.Height - CountLabel.Size.Height);
19622008
}
19632009
private void DisposeCountLabel()

Client/MirControls/MirScene.cs

+13
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ public virtual void ProcessPacket(Packet p)
190190
case (short)ServerPacketIds.NewQuestInfo:
191191
NewQuestInfo((S.NewQuestInfo)p);
192192
break;
193+
case (short)ServerPacketIds.NewRecipeInfo:
194+
NewRecipeInfo((S.NewRecipeInfo)p);
195+
break;
193196
}
194197
}
195198

@@ -203,6 +206,16 @@ private void NewQuestInfo(S.NewQuestInfo info)
203206
GameScene.QuestInfoList.Add(info.Info);
204207
}
205208

209+
private void NewRecipeInfo(S.NewRecipeInfo info)
210+
{
211+
GameScene.RecipeInfoList.Add(info.Info);
212+
213+
GameScene.Bind(info.Info.Item);
214+
215+
for (int j = 0; j < info.Info.Ingredients.Count; j++)
216+
GameScene.Bind(info.Info.Ingredients[j]);
217+
}
218+
206219
private static void Disconnect(S.Disconnect p)
207220
{
208221
switch (p.Reason)

Client/MirGraphics/DXManager.cs

+20
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class DXManager
4141
public static PixelShader MagicPixelShader;
4242
public static PixelShader ShadowPixelShader;
4343

44+
public static bool GrayScale;
45+
4446
public static Point[] LightSizes =
4547
{
4648
new Point(125,95),
@@ -226,6 +228,24 @@ public static void SetSurface(Surface surface)
226228
CurrentSurface = surface;
227229
Device.SetRenderTarget(0, surface);
228230
}
231+
public static void SetGrayscale(bool value)
232+
{
233+
GrayScale = value;
234+
235+
if (value == true)
236+
{
237+
if (Device.PixelShader == GrayScalePixelShader) return;
238+
Sprite.Flush();
239+
Device.PixelShader = GrayScalePixelShader;
240+
}
241+
else
242+
{
243+
if (Device.PixelShader == null) return;
244+
Sprite.Flush();
245+
Device.PixelShader = null;
246+
}
247+
}
248+
229249
public static void AttemptReset()
230250
{
231251
try

0 commit comments

Comments
 (0)