-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* good first take, test it * BugFixes after some testing ... * index fix * final clean up Co-authored-by: Bobo <Bobo@BOBO-GAME>
- Loading branch information
1 parent
442e876
commit 5b4317a
Showing
10 changed files
with
466 additions
and
373 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using GTA.UI; | ||
using LemonUI.Menus; | ||
using System; | ||
|
||
namespace Los.Santos.Dope.Wars.GUI.Elements | ||
{ | ||
/// <summary> | ||
/// The <see cref="BuyMenu"/> class serves as the buy menu at the right of the screen, abstracts from <see cref="NativeMenu"/> | ||
/// </summary> | ||
public class BuyMenu : NativeMenu | ||
{ | ||
/// <summary> | ||
/// The <see cref="BuyMenuShown"/> property | ||
/// </summary> | ||
public bool BuyMenuShown { get; private set; } | ||
|
||
/// <summary> | ||
/// The <see cref="BuyMenuClosed"/> property | ||
/// </summary> | ||
public bool BuyMenuClosed { get; private set; } | ||
|
||
/// <summary> | ||
/// The standard constructor with standard values | ||
/// </summary> | ||
/// <param name="title"></param> | ||
/// <param name="subtitle"></param> | ||
/// <param name="color"></param> | ||
public BuyMenu(string title, string subtitle, System.Drawing.Color color) : base(title, subtitle) | ||
{ | ||
Alignment = Alignment.Left; | ||
Banner.Color = color; | ||
ItemCount = CountVisibility.Always; | ||
Offset = new System.Drawing.PointF(Constants.ScreeSize.Width / 64, Constants.ScreeSize.Height / 36); | ||
UseMouse = false; | ||
TitleFont = Font.Pricedown; | ||
Closed += BuyMenu_Closed; | ||
Shown += BuyMenu_Shown; | ||
} | ||
|
||
private void BuyMenu_Shown(object sender, EventArgs e) | ||
{ | ||
BuyMenuClosed = false; | ||
BuyMenuShown = true; | ||
} | ||
|
||
private void BuyMenu_Closed(object sender, EventArgs e) | ||
{ | ||
BuyMenuClosed = true; | ||
BuyMenuShown = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
using LemonUI.Menus; | ||
using Los.Santos.Dope.Wars.Classes; | ||
using System; | ||
|
||
namespace Los.Santos.Dope.Wars.GUI.Elements | ||
{ | ||
/// <summary> | ||
/// The <see cref="DrugListItem"/> class serves as the buy and sell menu list item, abstracts from <see cref="NativeListItem{T}"/> | ||
/// </summary> | ||
public class DrugListItem : NativeListItem<int> | ||
{ | ||
#region fields | ||
private readonly bool _isPlayerItem; | ||
#endregion | ||
|
||
#region constructor | ||
/// <summary> | ||
/// The <see cref="DrugListItem"/> standard constructor | ||
/// </summary> | ||
/// <param name="drug"></param> | ||
/// <param name="isPlayerItem"></param> | ||
public DrugListItem(Drug drug, bool isPlayerItem = false) : base(drug.Name, GetIntArrayFromDrugQuantity(drug.Quantity)) | ||
{ | ||
_isPlayerItem = isPlayerItem; | ||
if (drug.Quantity.Equals(0)) | ||
Enabled = false; | ||
Tag = drug; | ||
SelectedIndex = drug.Quantity; | ||
LeftBadgeSet = GetDrugBadgeSet(drug.Name); | ||
RefreshDescription(drug, drug.Quantity, isPlayerItem); | ||
ItemChanged += OnItemChanged; | ||
} | ||
#endregion | ||
|
||
#region private methods | ||
/// <summary> | ||
/// The <see cref="OnItemChanged(object, ItemChangedEventArgs{int})"/> simply refreshes the item description if the item value has changed | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
private void OnItemChanged(object sender, ItemChangedEventArgs<int> e) | ||
{ | ||
if (Tag is not Drug drug) | ||
return; | ||
RefreshDescription(drug, e.Object, _isPlayerItem); | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="GetIntArrayFromDrugQuantity(int)"/> returns an array of integers starting from zero ... | ||
/// </summary> | ||
/// <param name="quantity"></param> | ||
/// <returns><see cref="Array"/></returns> | ||
private static int[] GetIntArrayFromDrugQuantity(int quantity) | ||
{ | ||
int[] array = new int[quantity + 1]; | ||
for (int i = 0; i <= quantity; i++) | ||
array[i] = i; | ||
return array; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="GetDrugBadgeSet(string)"/> method returns a corresponding badgeset | ||
/// </summary> | ||
/// <param name="drugName"></param> | ||
/// <returns><see cref="BadgeSet"/></returns> | ||
private static BadgeSet GetDrugBadgeSet(string drugName) | ||
{ | ||
BadgeSet cokeBadgeSet = new("mpinventory", "mp_specitem_coke", "mp_specitem_coke_black"); | ||
BadgeSet methBadgeSet = new("mpinventory", "mp_specitem_meth", "mp_specitem_meth_black"); | ||
BadgeSet weedBadgeSet = new("mpinventory", "mp_specitem_weed", "mp_specitem_weed_black"); | ||
BadgeSet heroBadgeSet = new("mpinventory", "mp_specitem_heroin", "mp_specitem_heroin_black"); | ||
BadgeSet defaultBadgeSet = new("mpinventory", "mp_specitem_cash", "mp_specitem_cash_black"); | ||
|
||
if (Enums.DrugTypes.Cocaine.ToString().Equals(drugName)) | ||
return cokeBadgeSet; | ||
if (Enums.DrugTypes.Heroin.ToString().Equals(drugName)) | ||
return heroBadgeSet; | ||
if (Enums.DrugTypes.Marijuana.ToString().Equals(drugName)) | ||
return weedBadgeSet; | ||
if (Enums.DrugTypes.Hashish.ToString().Equals(drugName)) | ||
return weedBadgeSet; | ||
if (Enums.DrugTypes.Mushrooms.ToString().Equals(drugName)) | ||
return weedBadgeSet; | ||
if (Enums.DrugTypes.Amphetamine.ToString().Equals(drugName)) | ||
return cokeBadgeSet; | ||
if (Enums.DrugTypes.PCP.ToString().Equals(drugName)) | ||
return cokeBadgeSet; | ||
if (Enums.DrugTypes.Methamphetamine.ToString().Equals(drugName)) | ||
return methBadgeSet; | ||
if (Enums.DrugTypes.Ketamine.ToString().Equals(drugName)) | ||
return cokeBadgeSet; | ||
if (Enums.DrugTypes.Mescaline.ToString().Equals(drugName)) | ||
return methBadgeSet; | ||
if (Enums.DrugTypes.Ecstasy.ToString().Equals(drugName)) | ||
return methBadgeSet; | ||
if (Enums.DrugTypes.Acid.ToString().Equals(drugName)) | ||
return methBadgeSet; | ||
if (Enums.DrugTypes.MDMA.ToString().Equals(drugName)) | ||
return methBadgeSet; | ||
if (Enums.DrugTypes.Crack.ToString().Equals(drugName)) | ||
return heroBadgeSet; | ||
if (Enums.DrugTypes.Oxycodone.ToString().Equals(drugName)) | ||
return methBadgeSet; | ||
else return defaultBadgeSet; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="RefreshDescription(Drug, int, bool)"/> method refreshes the item description | ||
/// </summary> | ||
/// <param name="drug"></param> | ||
/// <param name="drugQuantity"></param> | ||
/// <param name="isPlayerItem"></param> | ||
private void RefreshDescription(Drug drug, int drugQuantity, bool isPlayerItem) | ||
{ | ||
int valueOne = drug.CurrentPrice; | ||
int valueTwo = isPlayerItem ? drug.PurchasePrice : drug.AveragePrice; | ||
|
||
string pon = GetGoodOrBadPrice(valueOne, valueTwo, isPlayerItem); | ||
string inPercent = GetDifferenceInPercent(valueOne, valueTwo, isPlayerItem); | ||
|
||
Description = isPlayerItem ? $"Purchase price:\t${drug.PurchasePrice}\n" : $"Market price:\t\t${drug.AveragePrice}\n"; | ||
Description = Description + | ||
$"Current price:\t\t{pon}${drug.CurrentPrice} ({inPercent})\n" + | ||
$"~w~Purchase price:\t{drugQuantity} x {pon}${drug.CurrentPrice} ~w~= {pon}${drugQuantity * drug.CurrentPrice}"; | ||
} | ||
|
||
/// <summary> | ||
/// Returns price difference in percent, already colored | ||
/// </summary> | ||
/// <param name="valueOne">Should be the current price</param> | ||
/// <param name="valueTwo">Should be the market or purchase price</param> | ||
/// <param name="isPlayer"></param> | ||
/// <returns><see cref="string"/></returns> | ||
private static string GetDifferenceInPercent(int valueOne, int valueTwo, bool isPlayer = false) | ||
{ | ||
double resultValue = (valueOne / (double)valueTwo * 100) - 100; | ||
|
||
if (resultValue > 0) | ||
return $"{(isPlayer ? "~g~+" : "~r~+")}{resultValue:n2}%"; | ||
else if (resultValue < 0) | ||
return $"{(isPlayer ? "~r~" : "~g~")}{resultValue:n2}%"; | ||
else | ||
return $"~w~{resultValue:n2}%"; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the color it green, red or white string if it good, bad or neutral | ||
/// </summary> | ||
/// <param name="valueOne">Should be the current price</param> | ||
/// <param name="valueTwo">Should be the market or purchase price</param> | ||
/// <param name="isPlayer"></param> | ||
/// <returns><see cref="string"/></returns> | ||
private static string GetGoodOrBadPrice(int valueOne, int valueTwo, bool isPlayer = false) | ||
{ | ||
if (valueOne > valueTwo) | ||
return isPlayer ? "~g~" : "~r~"; | ||
if (valueOne < valueTwo) | ||
return isPlayer ? "~r~" : "~g~"; | ||
return "~w~"; | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using GTA.UI; | ||
using LemonUI.Menus; | ||
using System; | ||
|
||
namespace Los.Santos.Dope.Wars.GUI.Elements | ||
{ | ||
/// <summary> | ||
/// The <see cref="SellMenu"/> class serves as the sell menu at the left of the screen, abstracts from <see cref="NativeMenu"/> | ||
/// </summary> | ||
public class SellMenu : NativeMenu | ||
{ | ||
/// <summary> | ||
/// The <see cref="SellMenuShown"/> property | ||
/// </summary> | ||
public bool SellMenuShown { get; private set; } | ||
|
||
/// <summary> | ||
/// The <see cref="SellMenuClosed"/> property | ||
/// </summary> | ||
public bool SellMenuClosed { get; private set; } | ||
|
||
/// <summary> | ||
/// The standard constructor with standard values | ||
/// </summary> | ||
/// <param name="title"></param> | ||
/// <param name="subtitle"></param> | ||
/// <param name="color"></param> | ||
public SellMenu(string title, string subtitle, System.Drawing.Color color) : base(title, subtitle) | ||
{ | ||
Alignment = Alignment.Right; | ||
Banner.Color = color; | ||
ItemCount = CountVisibility.Always; | ||
Offset = new System.Drawing.PointF(-Constants.ScreeSize.Width / 64, Constants.ScreeSize.Height / 36); | ||
UseMouse = false; | ||
TitleFont = Font.Pricedown; | ||
Closed += SellMenu_Closed; | ||
Shown += SellMenu_Shown; | ||
} | ||
|
||
private void SellMenu_Shown(object sender, EventArgs e) | ||
{ | ||
SellMenuClosed = false; | ||
SellMenuShown = true; | ||
} | ||
|
||
private void SellMenu_Closed(object sender, EventArgs e) | ||
{ | ||
SellMenuClosed = true; | ||
SellMenuShown = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using GTA.UI; | ||
using LemonUI.Menus; | ||
using System; | ||
|
||
namespace Los.Santos.Dope.Wars.GUI.Elements | ||
{ | ||
/// <summary> | ||
/// The <see cref="StatisticsMenu"/> class serves as the statistics menu in the middle of the screen, abstracts from <see cref="NativeMenu"/> | ||
/// </summary> | ||
public class StatisticsMenu : NativeMenu | ||
{ | ||
/// <summary> | ||
/// The <see cref="StatisticsMenuShown"/> property | ||
/// </summary> | ||
public bool StatisticsMenuShown { get; private set; } | ||
|
||
/// <summary> | ||
/// The <see cref="StatisticsMenuClosed"/> property | ||
/// </summary> | ||
public bool StatisticsMenuClosed { get; private set; } | ||
|
||
|
||
/// <summary> | ||
/// The standard constructor with standard values | ||
/// </summary> | ||
/// <param name="title"></param> | ||
/// <param name="subtitle"></param> | ||
/// <param name="color"></param> | ||
public StatisticsMenu(string title, string subtitle, System.Drawing.Color color) : base(title, subtitle) | ||
{ | ||
Alignment = Alignment.Left; | ||
Banner.Color = color; | ||
ItemCount = CountVisibility.Never; | ||
Offset = new System.Drawing.PointF(Constants.ScreeSize.Width / 3, Constants.ScreeSize.Width / 3); | ||
UseMouse = false; | ||
Width = Constants.ScreeSize.Width / 3; | ||
Closed += StatisticsMenu_Closed; | ||
Shown += StatisticsMenu_Shown; | ||
} | ||
|
||
private void StatisticsMenu_Shown(object sender, EventArgs e) | ||
{ | ||
StatisticsMenuClosed = false; | ||
StatisticsMenuShown = true; | ||
} | ||
|
||
private void StatisticsMenu_Closed(object sender, EventArgs e) | ||
{ | ||
StatisticsMenuClosed = true; | ||
StatisticsMenuShown = false; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.