Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit gui3_shop;
- // -----------------------------------------------------------------------------
- interface
- // -----------------------------------------------------------------------------
- uses Forms, gui_main, sysutils, controls, cvar, toLanguage, uSoldier,
- uItem, tiRenderCloseUpModel, toGame, gui_Utils,
- vRender, toItemSession, PowerTypes, gui3_shopinv, game_ShopFilters,
- gui3_PrivateStore, Generics.Collections, Generics.Defaults;
- // -----------------------------------------------------------------------------
- type
- // -------------------------------------------------------------
- // -------------------------------------------------------------
- PGUIShopItem = ^TGUIShopItem;
- TGUIShopItem = record
- LimitedTime: int64;
- Item: TItem;
- cash_type: integer;
- lot_id: Cardinal;
- discount: Byte;
- count: integer;
- inbox: word;
- visible: boolean;
- IsPremium: boolean;
- end;
- // -------------------------------------------------------------
- TShopVisualMode = (svmList, svmThumbs);
- TGUINewShopList = class(TGUIControl)
- private
- fSB: TGUISmartScrollBar;
- fItemHeight: integer;
- ClientBorder: Cardinal;
- fMouseOverItem, fMouseOverExpander, fItemIndex: integer;
- fMx, fMy: integer;
- fExpandedItemsList: TList<Cardinal>;
- fExpandPressed: Cardinal;
- fVisualMode: TShopVisualMode;
- UpgradeTB, PriceTB: TGUIButton;
- procedure UpdateHint(const X, Y: integer);
- procedure SetVisualMode(const Value: TShopVisualMode);
- procedure DrawList(AbsLeft, AbsTop: integer);
- procedure DrawThumbs(AbsLeft, AbsTop: integer);
- public
- fItemList: TList<PGUIShopItem>;
- Loading: boolean;
- constructor Create(oLeft, oTop, oWidth, oHeight: integer; oParentControl: TGUIControl);
- procedure DoDraw; override;
- procedure Clear(ForceClear: boolean = false);
- procedure DoMouseUp(Button: TMouseButton; X, Y: integer); override;
- procedure DoMouseDown(Button: TMouseButton; X, Y: integer); override;
- procedure DoMouseMove(Button: TMouseButton; X, Y: integer); override;
- procedure DoMouseDoubleClick(X, Y: integer); override;
- procedure DoMouseWheelDown; override;
- procedure DoMouseWheelUp; override;
- procedure DoMouseEnter; override;
- procedure DoMouseLeave; override;
- procedure UpdateTrk;
- procedure Deselect;
- function GetSelectedItem: PGUIShopItem;
- function GetVisibleCount: Cardinal;
- destructor Destroy; override;
- property VisualMode: TShopVisualMode read fVisualMode write SetVisualMode;
- end;
- TGUIShop = class(TGUIControl)
- protected
- fCurIndex: integer;
- fitemsHeight: integer;
- fUpPressed: boolean;
- fDownPressed: boolean;
- fScrollPressed: boolean;
- OldY: integer;
- MouseY: integer;
- fTrkTop: integer;
- fTrkHeight: integer;
- // fOnChanged: tcdeclproc;
- fCount: integer;
- HideScrollBar: boolean;
- TotalHeight: integer;
- fMouseInItem: integer;
- // scrollbar : TGUIScrollBar;
- fFlipScroll: integer;
- fCurScroll: integer;
- public
- filterindex, owner_id: integer;
- Loading: boolean;
- items: TItems;
- property CurIndex: integer read fCurIndex; // write SetCurIndex;
- property CurScroll: integer read fCurScroll write fCurScroll;
- property TrkTop: integer read fTrkTop write fTrkTop;
- property ScrollPressed: boolean write fScrollPressed;
- constructor Create(oLeft, oTop, oW, oH: integer; oParentControl: TGUIControl);
- procedure DoDraw; override;
- procedure DoMouseDoubleClick(X, Y: integer); override;
- procedure DoMouseUp(Button: TMouseButton; X, Y: integer); override;
- procedure DoMouseDown(Button: TMouseButton; X, Y: integer); override;
- procedure DoMouseMove(Button: TMouseButton; X, Y: integer); override;
- procedure DoMouseWheelDown; override; // DOJ2
- procedure DoMouseWheelUp; override;
- procedure DoCancelClick; override; // DOJ1
- procedure UpdateTrk; virtual;
- procedure DoStep2(just_update: boolean);
- procedure DoStep; override;
- procedure ScrollDown;
- procedure Clear;
- procedure DeselectItem;
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_OpenSpecialShop(Filter: TExternalFilter);
- procedure GUI_ShowConsumableShop(shopId : integer);
- procedure GUI_AskAndOpenSpecialShop(QuestionCode: string; Filter: TExternalFilter);
- procedure GUI_Shop_Show;
- procedure Shop_ApplyFilters;
- procedure GUI_Shop_SendAllButtonsToReuse;
- procedure GUI_Shop_UpdateChar;
- procedure GUI_Shop_UpdateOverload(const Wei, Max: int64; const UpdatePosition: boolean = false);
- procedure GUI_Shop_GetCurrentWeight(var Wei: word; var Max: word);
- procedure GUI3_CreateShopWindow(var oInterface: TGUIInterface);
- procedure GUI_Shop_SetPointer(_type, owner_id: Cardinal; _items: TItems);
- procedure GUI_Bank_UpdateMoney;
- procedure window_shop_filter_Render(X, Y: integer);
- procedure gui_stop_click_premium; cdecl;
- procedure gui_stop_click_premium1; cdecl;
- procedure gui_stop_click_automaticauction; cdecl;
- procedure gui_stop_click_spectra_vendor; cdecl;
- procedure gui_stop_click_auction; cdecl;
- procedure gui_stop_click_dealers; cdecl;
- procedure gui_stop_click_mail; cdecl;
- procedure gui_stop_buy; cdecl;
- procedure Shop_SortNameDown; cdecl;
- procedure gui_shop_buy_cred; cdecl;
- procedure gui_shop_make_gold; cdecl;
- procedure process_adminbutton;
- procedure Shop_FilterOff; cdecl;
- procedure Shop_FilterSale; cdecl;
- procedure Shop_FilterDrops; cdecl;
- procedure Shop_FilterCustom; cdecl;
- // -----------------------------------------------------------------------------
- CONST
- GOLD_CRED_CONVERT_RATE = 50; // 1*50
- var
- last_shop_type: Byte = 0;
- last_shop_is_premium: boolean;
- GUI3_ShopItemList: TGUINewShopList;
- GUI3_ShopInventory: TShopInventory;
- // GUI3_FlushFilterBtn : TGUIButton;
- // -----------------------------------------------------------------------------
- implementation
- // -----------------------------------------------------------------------------
- uses math, Types, gui_wrapperN, Main, gs_pda, gui_window_simplequestion,
- netParsePacket, gui3_pdamap, net3_items, exe_wrap, titowns, menu_main,
- toItems, gui_hint_items, gui3_inventory, net3_assault, net3_AutomaticAuction,
- gui_window_sccart, g_Utils, gui3_Servers, toShowTimeNow, game_TutorialTips,
- net3_Checkpoint, gui_window_scshop, graph, MetacodeTemplates, game_Auction,
- AffiliateSystem, game_Dealers, game_Replays, game_Mail, game_Bonds, TDJXTextures,
- game_BuildOptions, game_Quotation, game_WeightBar, game_SquadPage, toDrop, DateUtils,
- game_SharedTypes, game_PlayersAuction, tiPackets, gui_SideHintButton,
- game_PremiumAccount, game_SCBOX, game_SpecialAuction, gui_hint, gui_ArtefactBoosters, gui_window_chat,
- game_TrueSkill, game_MultiShop;
- // -----------------------------------------------------------------------------
- var
- // GUI3_PremiumShopMenu : TButtonMenu;
- GUI3_PremiumShopFilter: TGUIShopFilters;
- ShopItemType: TShopItemType;
- shop_tutorial_area: TGUITutorialTipArea = nil;
- shop_count_edt: TGUIEdit;
- ExternalFilter: TExternalFilter = nil;
- GoToGlobalMap: boolean = true;
- ShopBuyBtn: TGUIButton;
- TotalRenderArea: TGUIRenderArea;
- // -----------------------------------------------------------------------------
- procedure process_adminbutton;
- var
- id, i: integer;
- begin
- id := GUIInterface.FindWindowByName('window_shop');
- if (id = -1) then
- begin
- Exit;
- end;
- if (GUIInterface.Windows[id].ControlsCount > 0) then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- begin
- if (GUIInterface.Windows[id].controls[i].Name = 'shop_admin') then
- begin
- GUIInterface.Windows[id].controls[i].visible :=
- (character.AccessLevel >= GameserverSettings.mailAdminAccess) and (ShopItemType <> itCustom);
- Exit;
- end;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure UpdateFiltersTop; cdecl;
- var
- id, i: integer;
- T: integer;
- begin
- T := 40;
- id := GUIInterface.FindWindowByName('window_shop_filter');
- if id = -1 then
- Exit;
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- begin
- if GUIInterface.Windows[id].controls[i] is TGUIButton then
- if GUIInterface.Windows[id].controls[i].visible then
- begin
- GUIInterface.Windows[id].controls[i].Top := T;
- Inc(T, 32);
- end;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure GuiShopSenderClick(Sender: TGUIControl); cdecl;
- var
- Shop: TGUINewShopList;
- begin
- if Sender = nil then
- Exit;
- if not(Sender is TGUINewShopList) then
- Exit;
- Shop := (Sender as TGUINewShopList);
- if (Shop.fItemIndex >= 0) and (Shop.fItemIndex < Shop.fItems.count) then
- begin
- GUI3_ShopInventory.SetSelectedItem(Shop.fItemList[Shop.fItemIndex].Item);
- GUI3_SCCartInventory.SetSelectedItem(Shop.fItemList[Shop.fItemIndex].Item);
- end
- else
- begin
- GUI3_ShopInventory.SetNoSelected;
- GUI3_SCCartInventory.SetNoSelected;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_Shop_SendAllButtonsToReuse;
- var
- id, i: integer;
- btn: TGUIButton;
- begin
- id := GUIInterface.FindWindowByName('window_shop_filter');
- if id = -1 then
- Exit;
- CharShowTimeStatistic.RECV_Time;
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- begin
- if GUIInterface.Windows[id].controls[i] is TGUIButton then
- begin
- btn := (GUIInterface.Windows[id].controls[i] as TGUIButton);
- btn.reuse_delay := CharShowTimeStatistic.cstTimesCount * 30 + 60;
- btn.GoToReuse;
- end;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_Shop_GetCurrentWeight(var Wei: word; var Max: word);
- var
- id, i: integer;
- selected_soldier: integer;
- begin
- selected_soldier := -1;
- if (InMainMenu()) then
- begin
- if (CanUseRenderCloseUpModelSoldier()) then
- begin
- selected_soldier := RenderCloseUpModel_soldier_id;
- end;
- end
- else
- begin
- selected_soldier := GetSelectedSoldierID();
- end;
- if (selected_soldier = -1) then
- begin
- Exit;
- end;
- Wei := soldiers[selected_soldier].weight;
- Max := soldiers[selected_soldier].max_weight;
- if (GUI_WindowVisible('window_exchange')) then
- begin
- id := GUIInterface.FindWindowByName('window_exchange');
- if id = -1 then
- Exit;
- end
- else
- begin
- id := GUIInterface.FindWindowByName('window_squad_page');
- if id = -1 then
- Exit;
- end;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- begin
- if (GUIInterface.Windows[id].controls[i] is TGUIWeightBar) then
- begin
- Wei := (GUIInterface.Windows[id].controls[i] as TGUIWeightBar).Position;
- Max := (GUIInterface.Windows[id].controls[i] as TGUIWeightBar).Max;
- break;
- end;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_Shop_UpdateOverload(const Wei, Max: int64; const UpdatePosition: boolean = false);
- begin
- GUI3_SetOverload('window_shop', Wei, Max, UpdatePosition);
- GUI3_SetOverload('window_sccart', Wei, Max, UpdatePosition);
- GUI3_SetOverload('window_exchange', Wei, Max, UpdatePosition);
- GUI3_SetOverload('window_inventory', Wei, Max, UpdatePosition);
- GUI3_SetOverload('window_squad_page', Wei, Max, UpdatePosition);
- GUI3_SetOverload('window_mercenaries_selector', Wei, Max, UpdatePosition);
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_Shop_UpdateChar;
- var
- id, i { , k } : integer;
- begin
- id := MercenariesList_GetSelectedIndex();
- if (id = -1) or (not CanUseRenderCloseUpModelSoldier()) then
- begin
- MercenariesList_SelectPrevious();
- end
- else
- begin
- RenderCloseUpModel_SetSource(id);
- end;
- GUI3_ShopInventory.UpdateCharName;
- GUI3_SCCartInventory.UpdateCharName;
- id := GUIInterface.FindWindowByName('window_shop');
- if not GUIInterface.Windows[id].visible then
- id := GUIInterface.FindWindowByName('window_sccart');
- if not GUIInterface.Windows[id].visible then
- Exit;
- if id = -1 then
- Exit;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- begin
- if (GUIInterface.Windows[id].controls[i] is TGUIShop) then
- begin
- (GUIInterface.Windows[id].controls[i] as TGUIShop).owner_id :=
- soldiers[RenderCloseUpModel_soldier_id].obj_id;
- // if Assigned((GUIInterface.Windows[id].Controls[i] as TGUIShop).OnSenderClick) then (GUIInterface.Windows[id].Controls[i] as TGUIShop).OnSenderClick((GUIInterface.Windows[id].Controls[i] as TGUIShop));
- (GUIInterface.Windows[id].controls[i] as TGUIShop).OnClick.Call;
- break;
- end;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_Bank_UpdateMoney;
- var
- id, i: integer;
- begin
- id := GUIInterface.FindWindowByName('window_bank');
- if id = -1 then
- Exit;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUILabel then
- begin
- if TGUILabel(GUIInterface.Windows[id].controls[i]).Name = 'cred_count' then
- TGUILabel(GUIInterface.Windows[id].controls[i]).caption :=
- Format(GetTranslation('ba01'), [inttostr(character.Credits)]);
- if TGUILabel(GUIInterface.Windows[id].controls[i]).Name = 'goldcred_count' then
- TGUILabel(GUIInterface.Windows[id].controls[i]).caption :=
- Format(GetTranslation('ba03'), [inttostr(character.GoldCredits)]);
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_Shop_SetPointer(_type, owner_id: Cardinal; _items: TItems);
- var
- id, i, j: integer;
- scroll_backup, trk_top_backup: integer;
- update_needed: boolean;
- begin
- id := GUIInterface.FindWindowByName('window_shop');
- if id = -1 then
- Exit;
- update_needed := last_shop_type = _type;
- last_shop_type := _type;
- if _type = 3 then
- GUIInterface.Windows[id].caption := GetTranslation('mn99') + ' - ' + GetTranslation('m117')
- else
- GUIInterface.Windows[id].caption := GetTranslation('mn99') + ' - ' + GetTranslation('m10' + inttostr(2 + _type));
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUIShop then
- begin
- scroll_backup := TGUIShop(GUIInterface.Windows[id].controls[i]).CurScroll;
- trk_top_backup := TGUIShop(GUIInterface.Windows[id].controls[i]).TrkTop;
- TGUIShop(GUIInterface.Windows[id].controls[i]).Clear;
- // TGUIShop(GUIInterface.Windows[id].Controls[i]).
- SetLength(TGUIShop(GUIInterface.Windows[id].controls[i]).items, Length(_items));
- TGUIShop(GUIInterface.Windows[id].controls[i]).items := _items;
- for j := 0 to high(_items) do
- TGUIShop(GUIInterface.Windows[id].controls[i]).items[j] := _items[j];
- TGUIShop(GUIInterface.Windows[id].controls[i]).UpdateTrk;
- TGUIShop(GUIInterface.Windows[id].controls[i]).DoStep;
- TGUIShop(GUIInterface.Windows[id].controls[i]).owner_id := owner_id;
- TGUIShop(GUIInterface.Windows[id].controls[i]).Loading := false;
- if (update_needed) then
- begin
- TGUIShop(GUIInterface.Windows[id].controls[i]).CurScroll := scroll_backup;
- TGUIShop(GUIInterface.Windows[id].controls[i]).TrkTop := trk_top_backup;
- TGUIShop(GUIInterface.Windows[id].controls[i]).DoStep2(true);
- end;
- break;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure window_shop_filter_Render(X, Y: integer);
- begin
- if not assigned(Common_Underlay.texture) then
- Exit;
- // )
- // Common_Underlay.draw(x,y,$FFFFFFFF, 0,0,0,1,1,False,True);
- Renderer_EffectCol(Common_Underlay, X, Y, $FFFFFFFF, 0, 0);
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_ShopSetLoading(Loading: boolean);
- // var id,i : integer;
- begin
- GUI3_ShopItemList.Loading := Loading;
- GUI_Shop_UpdateChar();
- refreshInventory(soldiers[RenderCloseUpModel_soldier_id].obj_id);
- end;
- // -----------------------------------------------------------------------------
- procedure gui_standartshopshow; cdecl;
- var
- id: integer;
- begin
- GoToGlobalMap := true;
- GUI_WindowHideShopGroup;
- GUI_WindowShow('window_shop');
- GUI_CenterWindowInsidePDA('window_shop');
- id := GUIInterface.FindWindowByName('window_shop');
- GUIInterface.Windows[id].caption := GetTranslation('mn99');
- if GUIInterface.Windows[id].Left < 256 + 82 then
- GUIInterface.Windows[id].Left := 256 + 82;
- if GUIInterface.Windows[id].Left + GUIInterface.Windows[id].Width > SCREEN_W then
- GUIInterface.Windows[id].Left := SCREEN_W - 80 - GUIInterface.Windows[id].Width;
- ShopItemType := itAll;
- CharShowTimeStatistic.RECV_Time;
- // if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.Visible := True and not GAME_BUILD_OPTION_NEW_SHOP_FILTER;
- if assigned(GUI3_PremiumShopFilter) then
- begin
- GUI3_PremiumShopFilter.visible := true;
- GUI3_PremiumShopFilter.MACRO_StdShopTypes;
- end;
- SEND_RequestItemShopList(0);
- GUI_ShopSetLoading(true);
- GUI_Shop_SendAllButtonsToReuse();
- // if assigned(GUI3_FlushFilterBtn) then GUI3_FlushFilterBtn.Visible := True;
- Shop_FilterOff();
- shop_tutorial_area.SetTutorialID(TIP_SHOP_SIMPLE);
- process_adminbutton();
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_OpenSpecialShop(Filter: TExternalFilter);
- var
- id: integer;
- begin
- ExternalFilter := Filter;
- GoToGlobalMap := false;
- GUI_WindowHideShopGroup;
- GUI_WindowShow('window_shop');
- GUI_CenterWindowInsidePDA('window_shop');
- id := GUIInterface.FindWindowByName('window_shop');
- GUIInterface.Windows[id].caption := GetTranslation('mn99');
- if GUIInterface.Windows[id].Left < 256 + 82 then
- GUIInterface.Windows[id].Left := 256 + 82;
- if GUIInterface.Windows[id].Left + GUIInterface.Windows[id].Width > SCREEN_W then
- GUIInterface.Windows[id].Left := SCREEN_W - 80 - GUIInterface.Windows[id].Width;
- GUI3_ShopItemList.Clear(true);
- ShopItemType := itCustom;
- CharShowTimeStatistic.RECV_Time;
- // if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.Visible := false and not GAME_BUILD_OPTION_NEW_SHOP_FILTER;
- if assigned(GUI3_PremiumShopFilter) then
- begin
- GUI3_PremiumShopFilter.visible := false;
- GUI3_PremiumShopFilter.ExternalFilter := Filter;
- GUI3_PremiumShopFilter.SelectedFilter := ShopItemType;
- end;
- SEND_RequestItemShopList(0);
- SEND_RequestPremiumItemShopList(0);
- GUI_ShopSetLoading(true);
- GUI_Shop_SendAllButtonsToReuse();
- // if assigned(GUI3_FlushFilterBtn) then GUI3_FlushFilterBtn.Visible := false;
- Shop_FilterCustom;
- // shop_tutorial_area.SetTutorialID(TIP_SHOP_SIMPLE);
- process_adminbutton();
- end;
- procedure GUI_ShowConsumableShop(shopId : integer);
- var id : integer;
- begin
- GoToGlobalMap := false;
- GUI_WindowHideShopGroup;
- GUI_WindowShow('window_shop');
- GUI_CenterWindowInsidePDA('window_shop');
- id := GUIInterface.FindWindowByName('window_shop');
- GUIInterface.Windows[id].caption := GetTranslation('tcs_c08');
- if GUIInterface.Windows[id].Left < 256 + 82 then
- GUIInterface.Windows[id].Left := 256 + 82;
- if GUIInterface.Windows[id].Left + GUIInterface.Windows[id].Width > SCREEN_W then
- GUIInterface.Windows[id].Left := SCREEN_W - 80 - GUIInterface.Windows[id].Width;
- GUI3_ShopItemList.Clear(true);
- CharShowTimeStatistic.RECV_Time;
- if assigned(GUI3_PremiumShopFilter) then
- begin
- GUI3_PremiumShopFilter.visible := false;
- GUI3_PremiumShopFilter.SelectedFilter := itAll;
- end;
- SEND_RequestItems(shopId);
- GUI_ShopSetLoading(true);
- // GUI_Shop_SendAllButtonsToReuse();
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_AskAndOpenSpecialShop(QuestionCode: string; Filter: TExternalFilter);
- begin
- ExternalFilter := Filter;
- GUI_SimpleQuestionWindowSetText(GetTranslation(QuestionCode), '');
- GUI_SimpleQuestionWindowSetAnonymCallBack(
- procedure()
- begin
- GUI_OpenSpecialShop(ExternalFilter);
- end, nil);
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_fair; cdecl;
- // var id : integer;
- begin
- GUI_WindowHideShopGroup;
- if (GameserverSettings.FairRentEnabled) then
- begin
- GUI_WindowShow('window_fairrent');
- SEND_RequestPremiumItemShopList(6);
- end
- else
- begin
- GUI_WindowShow('window_fairshop');
- SEND_RequestPremiumItemShopList(5);
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_automaticauction; cdecl;
- // var id : integer;
- begin
- GUI_WindowHideShopGroup;
- GUI_WindowShow('window_scshop');
- SEND_RequestItemMallList();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_rentshop; cdecl;
- // var id : integer;
- begin
- GUI_WindowHideShopGroup;
- GUI_WindowShow('window_rentshop');
- SEND_RequestRentalMallLots();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_spectra_vendor; cdecl;
- // var id : integer;
- begin
- GUI_WindowHideShopGroup;
- GUI_WindowShow('window_spectra_vendor');
- SEND_RequestCrystalPriceHistory();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_auction; cdecl;
- begin
- GUI_WindowHideShopGroup;
- ShowAuctionWindow();
- RequestCurrentAuctionList();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_dealers; cdecl;
- begin
- GUI_WindowHideShopGroup;
- SEND_RequestDealersList();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_mail; cdecl;
- begin
- SEND_RequestMailPackages();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_quotation; cdecl;
- begin
- GUI_WindowHideShopGroup;
- GUI3_ShowQuotationWindow();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_scbox; cdecl;
- begin
- GUI_WindowHideShopGroup;
- SEND_RequestSCBOXInfo();
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_market; cdecl;
- begin
- if (GameserverSettings.oldMartEnabled) then
- begin
- GUI_WindowHideShopGroup;
- RefreshPrivateStoresList();
- GUI_ShopSetLoading(true);
- GUI_Shop_SendAllButtonsToReuse();
- end
- else
- begin
- CursorHint(GetTranslation('m1256'));
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_players_auction; cdecl;
- begin
- if (GameserverSettings.playersAuctionEnabled) then
- begin
- GUI_WindowHideShopGroup;
- ShowPlayersAuctionListWindow();
- end
- else
- begin
- CursorHint(GetTranslation('m714'));
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_premium_common_1; cdecl;
- var
- id: integer;
- begin
- GUI_WindowHideShopGroup;
- GUI_WindowShow('window_shop');
- GUI_CenterWindowInsidePDA('window_shop');
- id := GUIInterface.FindWindowByName('window_shop');
- GUIInterface.Windows[id].caption := GetTranslation('m117');
- if GUIInterface.Windows[id].Left < 256 + 82 then
- GUIInterface.Windows[id].Left := 256 + 82;
- if GUIInterface.Windows[id].Left + GUIInterface.Windows[id].Width > SCREEN_W then
- GUIInterface.Windows[id].Left := SCREEN_W - 80 - GUIInterface.Windows[id].Width;
- // if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.Visible := True and not GAME_BUILD_OPTION_NEW_SHOP_FILTER;
- if assigned(GUI3_PremiumShopFilter) then
- begin
- GUI3_PremiumShopFilter.visible := true;
- GUI3_PremiumShopFilter.MACRO_PremiumTypes;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_premium_common_2; cdecl;
- begin
- GUI_ShopSetLoading(true);
- GUI_Shop_SendAllButtonsToReuse();
- // if assigned(GUI3_FlushFilterBtn) then GUI3_FlushFilterBtn.Visible := True;
- Shop_FilterOff();
- shop_tutorial_area.SetTutorialID(TIP_SHOP_PREMIUM);
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_premium; cdecl;
- // var id : integer;
- begin
- gui_stop_click_premium_common_1;
- { GUI_WindowHideShopGroup;
- GUI_WindowShow('window_shop');
- GUI_CenterWindowInsidePDA ('window_shop');
- id := GUIInterface.FindWindowByName('window_shop');
- GUIInterface.Windows[id].Caption := GetTranslation('m117');
- if GUIInterface.Windows[id].Left < 256 + 82 then GUIInterface.Windows[id].Left := 256 + 82;
- if GUIInterface.Windows[id].Left + GUIInterface.Windows[id].Width > SCREEN_W then
- GUIInterface.Windows[id].Left := SCREEN_W - 80 - GUIInterface.Windows[id].Width;
- if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.Visible := True and not GAME_BUILD_OPTION_NEW_SHOP_FILTER;
- if assigned(GUI3_PremiumShopFilter) then begin
- GUI3_PremiumShopFilter.Visible := true and GAME_BUILD_OPTION_NEW_SHOP_FILTER;
- GUI3_PremiumShopFilter.MACRO_PremiumTypes;
- end; }
- SEND_RequestPremiumItemShopList(0);
- gui_stop_click_premium_common_2;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_click_premium1; cdecl;
- // var id : integer;
- begin
- { GUI_WindowHideShopGroup;
- GUI_WindowShow('window_shop');
- GUI_CenterWindowInsidePDA ('window_shop');
- id := GUIInterface.FindWindowByName('window_shop');
- GUIInterface.Windows[id].Caption := GetTranslation('m117');
- if GUIInterface.Windows[id].Left < 256 + 82 then GUIInterface.Windows[id].Left := 256 + 82;
- if GUIInterface.Windows[id].Left + GUIInterface.Windows[id].Width > SCREEN_W then
- GUIInterface.Windows[id].Left := SCREEN_W - 80 - GUIInterface.Windows[id].Width;
- if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.Visible := True and not GAME_BUILD_OPTION_NEW_SHOP_FILTER;
- if assigned(GUI3_PremiumShopFilter) then begin
- GUI3_PremiumShopFilter.Visible := true and GAME_BUILD_OPTION_NEW_SHOP_FILTER;
- GUI3_PremiumShopFilter.MACRO_PremiumTypes;
- end; }
- gui_stop_click_premium_common_1;
- SEND_RequestPremiumItemShopList(1);
- gui_stop_click_premium_common_2;
- { GUI_ShopSetLoading(True);
- GUI_Shop_SendAllButtonsToReuse();
- if assigned(GUI3_FlushFilterBtn) then GUI3_FlushFilterBtn.Visible := True;
- Shop_FilterOff();
- shop_tutorial_area.SetTutorialID(TIP_SHOP_PREMIUM); }
- end;
- // -----------------------------------------------------------------------------
- procedure GUI_Shop_Show;
- var
- id: integer;
- i: Cardinal;
- its_gamble, its_prison,
- // its_base,
- its_training: boolean;
- begin
- GUI3_ShopInventory.SetNoSelected;
- GUI3_SCCartInventory.SetNoSelected;
- GUI_Shop_UpdateChar();
- process_adminbutton();
- its_gamble := Towns[current_town - 1].IsMinersTown { id = 9 };
- its_prison := (Towns[current_town - 1].Type_ = TYPE_JAIL { id = 10 } ) or
- (Towns[current_town - 1].IsTraining { id = 15 } ) or (Towns[current_town - 1].Shop = false);
- // its_base := Towns[current_town - 1].type_ = 1;
- its_training := Towns[current_town - 1].IsTraining;
- id := GUIInterface.FindWindowByName('window_shop_filter');
- if (id <> -1) then
- begin
- if (GUIInterface.Windows[id].ControlsCount > 0) then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- begin
- if (GUIInterface.Windows[id].controls[i] is TGUIButton) then
- with (GUIInterface.Windows[id].controls[i] as TGUIButton) do
- begin
- if (tag = 100) then
- begin
- visible := false;
- // if (its_prison) or (its_training) or (Towns[current_town - 1].id = 9) then
- // begin
- // visible := false;
- // end;
- end;
- if (tag = 104) then
- begin
- visible := GAME_BUILD_OPTION_SC_SHOP;
- end;
- if (tag = 105) then
- begin
- visible := GAME_BUILD_OPTION_RENT_SHOP;
- end;
- if (tag = 106) then
- begin
- visible := Towns[current_town - 1].Type_ in [TYPE_JAIL, TYPE_TOWN];
- // Super hardcode to miners town
- if (Towns[current_town - 1].IsMinersTown { id = 9 } ) then
- begin
- visible := false;
- end;
- if (its_prison) then
- begin
- visible := false;
- end;
- end;
- if (tag = 108) then
- begin // Auction
- visible := (Towns[current_town - 1].Type_ in [TYPE_JAIL, TYPE_TOWN]) and
- (GAME_BUILD_OPTION_AUCTION_ENABLED);
- end;
- if (tag = 109) then
- visible :=true;
- if (Towns[current_town - 1].id = 3) then
- begin
- visible := false;
- end;
- if (Towns[current_town - 1].id = 4) then
- begin
- visible := false;
- end;
- if (Towns[current_town - 1].id = 30) then
- begin
- visible := false;
- end;
- if (Towns[current_town - 1].id = 33) then
- begin
- visible := false;
- end;
- if (tag = 110) then
- begin
- visible := (its_prison = false);
- // and (character.AccessLevel >= GameserverSettings.mailAdminAccess);
- end;
- if (tag = 111) then
- begin
- visible := false; //GAME_BUILD_OPTION_QUOTATION_ENABLED;
- end;
- if (tag = 112) then
- begin
- visible := false; //Towns[current_town - 1].Type_ in [TYPE_JAIL, TYPE_TOWN];
- // Super hardcode to miners town
- if (Towns[current_town - 1].IsMinersTown { id = 9 } ) then
- // if (Towns[current_town - 1].IsMinersTown { id = 9 }) and (character.AccessLevel >=300) then
- begin
- visible := true;
- Enabled := visible;
- end;
- if (its_prison) then
- begin
- visible := false;
- end;
- end;
- if (tag = 115) then
- begin
- visible := (GameserverSettings.FairEnabled) or (GameserverSettings.FairRentEnabled);
- end;
- if (tag = 116) then
- begin
- visible := true;
- end;
- if (tag = 118) then
- begin
- visible := false;
- Enabled := visible;
- // if (Towns[current_town - 1].id = 4) then
- // begin
- // visible := false;
- // end;
- if (Towns[current_town - 1].id = 9) then
- begin
- visible := true;
- Enabled := visible;
- end;
- end;
- if (tag = 120) then
- begin
- visible := false; //TrueSkill_InTS_Town;
- Enabled := visible;
- end;
- if (tag = 121) then
- begin
- visible := Towns[current_town - 1].id = 33;
- Enabled := visible;
- end;
- if (tag = 122) then
- begin
- visible := false;
- // if (Towns[current_town - 1].id = 9) then
- // begin
- // visible := true;
- // Enabled := visible;
- // end;
- // if (Towns[current_town - 1].id = 11) then
- // begin
- // visible := true;
- // Enabled := visible;
- // end;
- // if (Towns[current_town - 1].id = 33) then
- // begin
- // visible := true;
- // end;
- end;
- // if (tag = 123) or (tag = 124) or (tag = 125) then
- if (tag = 123) then
- begin
- visible := false;
- if (Towns[current_town - 1].id = 30) then
- begin
- visible := true;
- Enabled := visible;
- end;
- end;
- if (tag = 127) then
- begin
- visible := false;
- Enabled := visible;
- end;
- if (tag = 124) then
- begin
- visible := false;
- if (Towns[current_town - 1].id = 30) then
- begin
- visible := true;
- Enabled := visible;
- end;
- end;
- if (tag = 125) then
- begin
- visible := false;
- if (Towns[current_town - 1].id = 3) then
- begin
- visible := true;
- Enabled := visible;
- end;
- end;
- // if (tag = 126) or (tag = 127) or (tag = 128) then
- if (tag = 126) then
- begin
- visible := false;
- if (Towns[current_town - 1].id = 3) then
- begin
- visible := true;
- Enabled := visible;
- end;
- end;
- if (tag = 128) then
- begin
- visible := Towns[current_town - 1].id = 33;
- Enabled := visible;
- end;
- if (tag = 103) then
- begin
- Visible := false;
- if (Towns[current_town - 1].id = 9) then
- begin
- visible := true;
- Enabled := visible;
- end;
- if (Towns[current_town - 1].id = 11) then
- begin
- visible := true;
- Enabled := visible;
- end;
- if (Towns[current_town - 1].id = 33) then
- begin
- visible := false;
- Enabled := visible;
- end;
- // OnClick.Clear;
- // if (its_gamble) then
- // begin
- // OnClick.Subscribe(gui_stop_click_premium1); // 1
- // end
- // else
- // begin
- // OnClick.Subscribe(gui_stop_click_premium);
- // end;
- end;
- end;
- end;
- end;
- id := GUIInterface.FindWindowByName('window_shop_filter');
- GUIInterface.Windows[id].visible := true;
- id := GUIInterface.FindWindowByName('window_shop');
- GUIInterface.Windows[id].CenterOnScreen;
- if GUIInterface.Windows[id].Left + GUIInterface.Windows[id].Width > SCREEN_W - 340 then
- GUIInterface.Windows[id].Left := SCREEN_W - 340 - GUIInterface.Windows[id].Width;
- if (its_prison) then
- begin
- Game_soldiers_actions_blocked_ := false;
- // gui_stop_click_premium;
- Game_soldiers_actions_blocked_ := true;
- end;
- // gui_PetShop_Refresh;
- ShowShopMenu;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_shop_convert_cred; cdecl;
- var
- id, i: integer;
- cred: string;
- begin
- id := GUIInterface.FindWindowByName('window_bank');
- if id = -1 then
- Exit;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUIEdit then
- begin
- TGUIEdit(GUIInterface.Windows[id].controls[i]).Text :=
- trim(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text);
- if GUIInterface.Windows[id].controls[i].Name = 'edit_convert' then
- cred := TGUIEdit(GUIInterface.Windows[id].controls[i]).Text;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_shop_buy_cred; cdecl;
- var
- id, i: integer;
- cred: string;
- // const BUYLINK : 12345&login=needle&service=0&amount=20
- begin
- id := GUIInterface.FindWindowByName('window_bank');
- if id = -1 then
- Exit;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUIEdit then
- begin
- TGUIEdit(GUIInterface.Windows[id].controls[i]).Text :=
- trim(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text);
- if GUIInterface.Windows[id].controls[i].Name = 'edit_buycred' then
- cred := TGUIEdit(GUIInterface.Windows[id].controls[i]).Text;
- if cred = '0' then
- Exit;
- // Application.Minimize;
- if not ENGLISH_SERVER then
- begin
- if (AffiliateBankLinkOverride) then
- begin
- GoWebsite(AffiliateBankLinkValue + '?account=' + Cvar_VariableString('orange_login') + '&character=' +
- character.Name + '&language=' + Cvar_VariableString('g_language') + '&server=' +
- inttostr(GlobalSelectedServer + 1) + '&wait', true);
- end
- else
- begin
- GoWebsite('http://ti.ggeek.ru/?action=pay&account=' + Cvar_VariableString('orange_login') + '&char=' +
- character.Name);
- end;
- end
- else
- begin
- GoWebsite('http://billing.totalinfluenceonline.com/eng/bills/?do=create&project_id=34' + '&account=' +
- Cvar_VariableString('orange_login') + '&character=' + character.Name + '&server=' +
- inttostr(GlobalSelectedServer + 1) + '&wait', true);
- end;
- // GUI3_PDA_ShopClick;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_shop_make_gold; cdecl;
- begin
- Application.Minimize;
- if not ENGLISH_SERVER then
- begin
- GoWebsite('http://bank.tionline.ru/ftp.php?' + 'server=' + inttostr(GlobalSelectedServer + 1) + '&char_name=' +
- character.Name + '');
- end
- else
- begin
- end;
- GUI3_PDA_ShopClick;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_shop_convert_edit_change; cdecl;
- var
- id, i: integer;
- cred: integer;
- // const BUYLINK : 12345&login=needle&service=0&amount=20
- begin
- id := GUIInterface.FindWindowByName('window_bank');
- if id = -1 then
- Exit;
- cred := 0;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUIEdit then
- begin
- try
- if GUIInterface.Windows[id].controls[i].Name = 'edit_convert' then
- if Length(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text) > 0 then
- cred := strtoint(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text);
- except
- cred := 0;
- break;
- end;
- end;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUILabel then
- begin
- if TGUILabel(GUIInterface.Windows[id].controls[i]).Name = 'convertrate' then
- TGUILabel(GUIInterface.Windows[id].controls[i]).caption :=
- Format(GetTranslation('ba07'), [inttostr(cred * GOLD_CRED_CONVERT_RATE)]);
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure Click_shift_L; cdecl;
- var
- id, i, cnt: integer;
- begin
- id := GUIInterface.FindWindowByName('window_bank');
- if id = -1 then
- Exit;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUIEdit then
- begin
- if Length(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text) = 0 then
- Exit;
- cnt := strtoint(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text);
- if cnt > 3000 then
- dec(cnt, 1000)
- else if cnt > 1000 then
- dec(cnt, 100)
- else if cnt > 250 then
- dec(cnt, 50)
- else if cnt > 50 then
- dec(cnt, 10)
- else if cnt > 15 then
- dec(cnt, 5)
- else
- dec(cnt);
- if cnt < 0 then
- cnt := 0;
- TGUIEdit(GUIInterface.Windows[id].controls[i]).Text := inttostr(cnt);
- Exit;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure Click_shift_R; cdecl;
- var
- id, i, cnt: integer;
- begin
- id := GUIInterface.FindWindowByName('window_bank');
- if id = -1 then
- Exit;
- if GUIInterface.Windows[id].ControlsCount > 0 then
- for i := 0 to GUIInterface.Windows[id].ControlsCount - 1 do
- if GUIInterface.Windows[id].controls[i] is TGUIEdit then
- begin
- if Length(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text) = 0 then
- Exit;
- cnt := strtoint(TGUIEdit(GUIInterface.Windows[id].controls[i]).Text);
- if cnt < 15 then
- Inc(cnt)
- else if cnt < 50 then
- Inc(cnt, 5)
- else if cnt < 250 then
- Inc(cnt, 10)
- else if cnt < 1000 then
- Inc(cnt, 50)
- else if cnt < 3000 then
- Inc(cnt, 100)
- else
- Inc(cnt, 1000);
- TGUIEdit(GUIInterface.Windows[id].controls[i]).Text := inttostr(cnt);
- TGUIEdit(GUIInterface.Windows[id].controls[i]).CursorPos := Length(inttostr(cnt));
- Exit;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure gui_stop_buy; cdecl;
- var
- // {id,} i : integer;
- owner_id: integer;
- edt_cnt: int64;
- icount, iprice, iname: String;
- begin
- if (GUI3_ShopItemList.fItemIndex = -1) or (GUI3_ShopItemList.fItemIndex >= GUI3_ShopItemList.fItemList.count) then
- begin
- Exit;
- end;
- edt_cnt := StrToInt64Def(shop_count_edt.Text, 0);
- if (edt_cnt = 0) then
- begin
- Exit;
- end;
- if TrueSkill_InTS_Town() and (last_shop_type = 15) then begin
- with GUI3_ShopItemList do
- begin
- SEND_RequestItemBuy(15, fItemList[fItemIndex].Item.Item_id , fItemList[fItemIndex].count * edt_cnt, fItemList[fItemIndex].cash_type);
- Exit;
- end;
- end;
- if (edt_cnt > 1) then
- begin
- with GUI3_ShopItemList do
- begin
- icount := inttostr(edt_cnt) + ' (' + inttostr(fItemList[fItemIndex].Item.count * edt_cnt) + ')';
- if (fItemList[fItemIndex].cash_type > 2) then
- begin
- iprice := inttostr(fItemList[fItemIndex].Item.price * edt_cnt) + ' ' + GameItemDatas
- [GetGameItemData_byID(fItemList[fItemIndex].cash_type)].Name;
- end
- else if (fItemList[fItemIndex].Item.price <> 0) then
- begin
- iprice := inttostr(fItemList[fItemIndex].Item.price * edt_cnt) + ' cr';
- end
- else
- begin
- iprice := inttostr(fItemList[fItemIndex].Item.GoldPrice * edt_cnt) + ' gold';
- end;
- iname := fItemList[fItemIndex].Item.GetName;
- // QuotedStr(GetItemNameByID(fItemList[fItemIndex].Item.item_id));
- end;
- GUI_SimpleQuestionWindowSetText(Format(GetTranslation('m1261'), [icount, iname, iprice]), '');
- GUI_SimpleQuestionWindowSetAnonymCallBack(
- procedure()
- var
- edt_cnt: int64;
- begin
- if (GUI3_ShopItemList.fItemIndex = -1) then
- begin
- Exit;
- end;
- edt_cnt := StrToInt64Def(shop_count_edt.Text, 0);
- if (edt_cnt = 0) then
- begin
- Exit;
- end;
- owner_id := soldiers[RenderCloseUpModel_soldier_id].obj_id;
- with GUI3_ShopItemList do
- begin
- if { (last_shop_is_premium) } fItemList[fItemIndex].IsPremium then
- begin
- SEND_RequestPremiumItemShopBuy(owner_id, fItemList[fItemIndex].Item.obj_id, edt_cnt)
- end
- else
- begin
- SEND_RequestItemShopBuy(owner_id, fItemList[fItemIndex].Item.obj_id, edt_cnt, last_shop_type);
- end;
- end;
- if ShopItemType = itCustom then
- with GUI3_ShopItemList do
- begin
- TGUIWindow(GUI3_ShopItemList.ParentWindow).Hide;
- GUI3_ShopItemList.Clear(true);
- end;
- shop_count_edt.Text := '0';
- end,
- procedure()
- begin
- end);
- GUI_WindowShowModal('window_simplequestion');
- Exit;
- end;
- owner_id := soldiers[RenderCloseUpModel_soldier_id].obj_id;
- with GUI3_ShopItemList do
- begin
- if { (last_shop_is_premium) } fItemList[fItemIndex].IsPremium then
- begin
- SEND_RequestPremiumItemShopBuy(owner_id, fItemList[fItemIndex].Item.obj_id, edt_cnt)
- end
- else
- begin
- SEND_RequestItemShopBuy(owner_id, fItemList[fItemIndex].Item.obj_id, edt_cnt, last_shop_type);
- end;
- end;
- if ShopItemType = itCustom then
- with GUI3_ShopItemList do
- begin
- TGUIWindow(GUI3_ShopItemList.ParentWindow).Hide;
- GUI3_ShopItemList.Clear(true);
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure RenderBankLogo(X, Y: integer);
- begin
- Renderer_RenderEffect(FindTexture('bank_logo'), X, Y, 0, 0);
- end;
- // ------------------------------------------------------------------------------
- procedure SetupShopWindowControlsCommon;
- begin
- GUI3_ShopItemList.UpgradeTB.Left := GUI3_ShopItemList.Left + 2;
- GUI3_ShopItemList.PriceTB.Left := GUI3_ShopItemList.Left + 2 + 64 + 208 + 2;
- GUI3_ShopItemList.UpgradeTB.Top := GUI3_ShopItemList.Top - 18 - 10 - 3;
- GUI3_ShopItemList.PriceTB.Top := GUI3_ShopItemList.Top - 18 - 10 - 3;
- TotalRenderArea.Left := shop_count_edt.Left + shop_count_edt.Width + 5;
- TotalRenderArea.Top := shop_count_edt.Top;
- end;
- // ------------------------------------------------------------------------------
- procedure SetupShopWindowControlsCustom;
- begin
- GUI3_ShopItemList.Height := 210;
- GUI3_ShopItemList.Left := 10;
- GUI3_ShopItemList.Top := 60;
- ShopBuyBtn.Left := (ShopBuyBtn.ParentWindow.Width - ShopBuyBtn.Width) div 2 + 180 div 2;
- ShopBuyBtn.Top := ShopBuyBtn.ParentWindow.Height - 44;
- { GUI3_ShopItemList.UpgradeTB.Left := GUI3_ShopItemList.Left + 2;
- GUI3_ShopItemList.UpgradeTB.Top := GUI3_ShopItemList.Top - 18 - 10 - 3;
- GUI3_ShopItemList.PriceTB.Top := GUI3_ShopItemList.Top - 18 - 10 - 3;
- GUI3_ShopItemList.PriceTB.Left := GUI3_ShopItemList.Left + 2 + 64 + 208 + 2; }
- with shop_count_edt do
- begin
- Left := ShopBuyBtn.Left - 180;
- Top := ParentWindow.Height - 44;
- visible := true;
- end;
- SetupShopWindowControlsCommon;
- end;
- // ------------------------------------------------------------------------------
- procedure SetupShopWindowControlsRegular;
- begin
- GUI3_ShopItemList.Left := 165 - 10;
- GUI3_ShopItemList.Height := GUI3_ShopItemList.ParentWindow.Height - 86;
- GUI3_ShopItemList.Top := 50;
- ShopBuyBtn.Left := 165;
- ShopBuyBtn.Top := ShopBuyBtn.ParentWindow.Height - 34;
- with shop_count_edt do
- begin
- Left := 165 + 150 + 10;
- Top := ParentWindow.Height - 34;
- visible := true;
- end;
- SetupShopWindowControlsCommon;
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_ApplyFilters;
- var
- P: PGUIShopItem;
- id, tw, th: integer;
- drops, custom: boolean;
- begin
- // GUI3_ShopItemList : TGUINewShopList;
- drops := (ShopItemType in [itDrops]);
- custom := (ShopItemType in [itCustom]);
- GUI3_ShopInventory.SetVisible(not drops and not custom);
- if drops then
- begin
- GUI3_ShopItemList.Width := 640;
- GUI3_ShopItemList.VisualMode := svmThumbs;
- end
- else
- begin
- GUI3_ShopItemList.Width := 320 + 40;
- GUI3_ShopItemList.VisualMode := svmList;
- end;
- if custom then
- begin
- tw := 576 - 128 - 64;
- th := 320;
- SetupShopWindowControlsCustom;
- end
- else
- begin
- tw := 304 * 2 + 160 + 64;
- th := 512 - 128 + 32 + 32;
- SetupShopWindowControlsRegular;
- end;
- // приведение типа обязательно для вызова оконного SetWidth
- with GUI3_ShopItemList do
- if (ParentWindow.Width <> tw) or (ParentWindow.Height <> th) then
- begin
- TGUIWindow(ParentWindow).Width := tw;
- TGUIWindow(ParentWindow).Height := th;
- TGUIWindow(ParentWindow).CenterOnScreen;
- end;
- if GUI3_ShopItemList.fItemList.count > 0 then
- for P in GUI3_ShopItemList.fItemList do
- begin
- id := { GetGameItemData_byID(P.Item.item_id) } P.Item.GetItemIndex;
- P.visible := true;
- if assigned(GUI3_PremiumShopFilter) then
- begin
- P.visible := GUI3_PremiumShopFilter.IsItemMatchesCurrentFilter(P.Item);
- end
- else
- begin
- if (ShopItemType <> itAll) then
- begin
- case ShopItemType of
- itClothing:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_NONE) and
- ((GameItemDatas[id].p_def <> 0) or (GameItemDatas[id].armortype = I_ARMORTYPE_TANK));
- itClothingHead:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_NONE) and (GameItemDatas[id].p_def <> 0)
- and (GameItemDatas[id].bodypart = I_BODYPART_HEAD_);
- itClothingChest:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_NONE) and
- ((GameItemDatas[id].p_def <> 0) or (GameItemDatas[id].armortype = I_ARMORTYPE_TANK)) and
- ((GameItemDatas[id].bodypart = I_BODYPART_CHEST) or
- (GameItemDatas[id].bodypart = I_BODYPART_FULL_ARMOR) or
- (GameItemDatas[id].bodypart = I_BODYPART_COMPLEX_ARMOR));
- itClothingLegs:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_NONE) and (GameItemDatas[id].p_def <> 0)
- and (GameItemDatas[id].bodypart = I_BODYPART_LEGS);
- itWeapon:
- P.visible := (GameItemDatas[id].weaponType <> I_WEAPONTYPE_NONE);
- itWeaponMelee:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_MELEE);
- itWeaponLight:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_LIGHT);
- itWeaponAutomatic:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_AUTOMATIC);
- itWeaponDistance:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_DISTANCE);
- itWeaponHeavy:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_HEAVY);
- itWeaponThrowing:
- P.visible := (GameItemDatas[id].weaponType = I_WEAPONTYPE_THROWING);
- // itRare : P.visible := P.Item.IsRareItem();
- itSale:
- P.visible := (P.Item.SaleTag <> '') and not P.Item.IsDrop;
- itDrops:
- P.visible := (P.Item.IsDrop);
- itCustom:
- if not assigned(ExternalFilter) then
- P.visible := false
- else
- P.visible := ExternalFilter(P.Item);
- itSteroids:
- P.visible := P.Item.IsSteroid();
- itBlueprint:
- P.visible := P.Item.IsBlueprint();
- itAmmo:
- P.visible := (P.Item.IsConsumable());
- itMines:
- P.visible := P.Item.IsMine or P.Item.IsMineFinder or P.Item.IsMineDefuser;
- end;
- if P.Item.IsGoldOrCredits and not(ShopItemType in [itDrops, itCustom]) then
- P.visible := true;
- end;
- if (ShopItemType = itAll) and P.Item.IsDrop then
- P.visible := false;
- end;
- end;
- GUI3_ShopItemList.UpdateTrk;
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_FilterOff; cdecl;
- begin
- ShopItemType := itAll;
- { if assigned(GUI3_PremiumShopMenu) then begin
- GUI3_PremiumShopMenu.FlushColor;
- GUI3_PremiumShopMenu.UpdateColor( Integer(ShopItemType) );
- end; }
- if assigned(GUI3_PremiumShopFilter) then
- GUI3_PremiumShopFilter.SelectedFilter := ShopItemType;
- Shop_ApplyFilters();
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_FilterSale; cdecl;
- begin
- ShopItemType := itSale;
- { if assigned(GUI3_PremiumShopMenu) then begin
- GUI3_PremiumShopMenu.FlushColor;
- GUI3_PremiumShopMenu.UpdateColor( Integer(ShopItemType) );
- end; }
- if assigned(GUI3_PremiumShopFilter) then
- GUI3_PremiumShopFilter.SelectedFilter := ShopItemType;
- Shop_ApplyFilters();
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_FilterDrops; cdecl;
- begin
- ShopItemType := itDrops;
- { if assigned(GUI3_PremiumShopMenu) then begin
- GUI3_PremiumShopMenu.FlushColor;
- GUI3_PremiumShopMenu.UpdateColor( Integer(ShopItemType) );
- end; }
- if assigned(GUI3_PremiumShopFilter) then
- GUI3_PremiumShopFilter.SelectedFilter := ShopItemType;
- Shop_ApplyFilters();
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_FilterCustom; cdecl;
- begin
- ShopItemType := itCustom;
- { if assigned(GUI3_PremiumShopMenu) then begin
- GUI3_PremiumShopMenu.FlushColor;
- GUI3_PremiumShopMenu.UpdateColor( Integer(ShopItemType) );
- end; }
- if assigned(GUI3_PremiumShopFilter) then
- GUI3_PremiumShopFilter.SelectedFilter := ShopItemType;
- Shop_ApplyFilters();
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_FilterOn(Sender: TGUIControl); cdecl;
- begin
- if Sender is TGUIShopFilters then
- begin
- ShopItemType := TGUIShopFilters(Sender).SelectedFilter;
- Shop_ApplyFilters();
- Exit;
- end;
- if (Sender as TGUIButton).CaptionColor <> SC_SELECTED_BUTTON_COLOR then
- begin
- // if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.FlushColor;
- (Sender as TGUIButton).CaptionColor := SC_SELECTED_BUTTON_COLOR;
- ShopItemType := TShopItemType((Sender as TGUIButton).tag);
- end
- else
- begin
- // if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.FlushColor;
- ShopItemType := itAll;
- end;
- Shop_ApplyFilters();
- // if assigned(GUI3_PremiumShopMenu) then GUI3_PremiumShopMenu.UpdateColor( Integer(ShopItemType) );
- end;
- // -----------------------------------------------------------------------------
- procedure DoShopHide; cdecl;
- begin
- if GoToGlobalMap then
- GS_SetGlobalPage_Shops
- else
- GUI_WindowHide('window_shop');
- end;
- // -----------------------------------------------------------------------------
- procedure GUI3_CreateShopWindow(var oInterface: TGUIInterface);
- var
- btn: TGUIButton;
- shbtn: TGUISideHintButton;
- label1: TGUILabel;
- wnd: TGUIWindow;
- edit: TGUIEdit;
- ra: TGUIRenderArea;
- L: Cardinal;
- begin
- // -------------------
- // test sign in window
- wnd := TGUIWindow.Create(oInterface);
- wnd.Name := 'window_shop';
- wnd.texture := Common_Window2;
- wnd.SetSize(10, 10, 304 * 2 + 160 + 64, 512 - 128 + 32 + 32);
- wnd.MinWidth := 1;
- wnd.MinHeight := 1;
- wnd.AllowDocking := true;
- wnd.AllowResizing := false;
- wnd.caption := GetTranslation('mn99');
- wnd.visible := true;
- wnd.CenterOnScreen;
- wnd.CloseBtn.ModalResult := mrCancel;
- wnd.CloseBtn.visible := true;
- wnd.CloseBtn.OnClick.Subscribe(DoShopHide);
- (*
- if not GAME_BUILD_OPTION_NEW_SHOP_FILTER then begin
- GUI3_PremiumShopMenu := TButtonMenu.Create(0, 30, 150, wnd);
- {with GUI3_PremiumShopMenu do begin
- Add(GetTranslation('m696'), 0, Byte(itSale), Shop_FilterOn);
- Add(GetTranslation('box_filter'), 0, Byte(itDrops), Shop_FilterOn);
- //Add(GetTranslation('m696'), 0, Byte(itRare), Shop_FilterOn);
- Add(GetTranslation('m699'), 0, Byte(itSteroids), Shop_FilterOn);
- Add(GetTranslation('m695'), 0, Byte(itBlueprint), Shop_FilterOn);
- Add(GetTranslation('m103'), 0, Byte(itClothing), Shop_FilterOn);
- Add(GetTranslation('m512'), 10, Byte(itClothingHead), Shop_FilterOn);
- Add(GetTranslation('m513'), 10, Byte(itClothingChest), Shop_FilterOn);
- Add(GetTranslation('m514'), 10, Byte(itClothingLegs), Shop_FilterOn);
- Add(GetTranslation('m403'), 0, Byte(itWeapon), Shop_FilterOn);
- Add(GetTranslation('m515'), 10, Byte(itWeaponMelee), Shop_FilterOn);
- Add(GetTranslation('m516'), 10, Byte(itWeaponLight), Shop_FilterOn);
- Add(GetTranslation('m517'), 10, Byte(itWeaponAutomatic), Shop_FilterOn);
- Add(GetTranslation('m518'), 10, Byte(itWeaponDistance), Shop_FilterOn);
- Add(GetTranslation('m519'), 10, Byte(itWeaponHeavy), Shop_FilterOn);
- Add(GetTranslation('m520'), 10, Byte(itWeaponThrowing), Shop_FilterOn);
- Add(GetTranslation('mine_category'), 10, Byte(itMines), Shop_FilterOn);
- Add(GetTranslation('m104'), 0, Byte(itAmmo), Shop_FilterOn);
- end;}
- GUI3_FlushFilterBtn := TGUIButton.Create(Common_Buttons3, wnd);
- with GUI3_FlushFilterBtn do begin
- Caption := GetTranslation('m369');
- Left := 0;
- Top := wnd.Height - 34;
- Width := 150;
- CaptionColor := $FF00FFFF;
- OnClick.Subscribe(Shop_FilterOff);
- end;
- GUI3_PremiumShopFilter := nil;
- end else begin
- GUI3_PremiumShopMenu := nil; *)
- // GUI3_FlushFilterBtn := nil;
- GUI3_PremiumShopFilter := TGUIShopFilters.Create(wnd);
- with GUI3_PremiumShopFilter do
- begin
- Left := 0;
- Top := 30;
- Width := 150;
- Height := ParentControl.Height - Top - 5;
- OnFilterChange.Subscribe(Shop_FilterOn);
- // OnFilterChange := Shop_FilterOn;
- end;
- // end;
- GUI3_ShopItemList := TGUINewShopList.Create(165 - 10, 50, 320 + 40, wnd.Height - 86, wnd);
- GUI3_ShopItemList.OnClick.Subscribe(GuiShopSenderClick);
- // Buy button
- btn := TGUIButton.Create(Common_Buttons3, wnd);
- btn.caption := GetTranslation('m107');
- btn.Left := 165 - 15;
- btn.Width := 150;
- btn.Top := wnd.Height - 34;
- btn.Align := guiInUpperCorner;
- btn.OnClick.Subscribe(gui_stop_buy);
- btn.reuse_delay := 36;
- btn.MouseTracerEnabled := true;
- ShopBuyBtn := btn;
- // Edit count
- shop_count_edt := TGUIEdit.Create(wnd);
- with shop_count_edt do
- begin
- Text := '0';
- Left := 165 + 150 + 10;
- Width := 50;
- Top := wnd.Height - 34;
- WorkMode := wmInteger;
- MaxLength := 5;
- end;
- TotalRenderArea := TGUIRenderArea.Create(shop_count_edt.Left + shop_count_edt.Width + 5, shop_count_edt.Top,
- 0, 0, wnd);
- with TotalRenderArea do
- begin
- RenderCallBackAnonymous := procedure(X, Y: integer)
- var
- cnt, edt_cnt, price: int64;
- buf: String;
- W: integer;
- P: PGUIShopItem;
- pt: Byte;
- begin
- edt_cnt := StrToInt64Def(shop_count_edt.Text, 0);
- if (GUI3_ShopItemList.fItemIndex <> -1) and (GUI3_ShopItemList.fItemList.count > GUI3_ShopItemList.fItemIndex)
- then
- begin
- P := GUI3_ShopItemList.fItemList[GUI3_ShopItemList.fItemIndex];
- cnt := P.Item.count;
- if (P.Item.price <> 0) then
- begin
- price := edt_cnt * P.Item.price;
- pt := 0;
- end
- else
- begin
- price := edt_cnt * P.Item.GoldPrice;
- pt := 1;
- end;
- end
- else
- begin
- cnt := 0;
- price := 0;
- pt := 0;
- end;
- buf := 'x' + inttostr(cnt) + ' = ';
- W := Visual.TextWidth(buf, PIXEL);
- Visual.Text(buf, X, Y);
- Visual.Text(inttostr(edt_cnt * cnt), X + W, Y);
- buf := inttostr(price);
- Visual.Text(buf, X + W, Y + 14);
- W := W + Visual.TextWidth(buf, PIXEL);
- end;
- end;
- // Admin button
- btn := TGUIButton.Create(Common_Buttons3, wnd);
- btn.caption := GetTranslation('m755');
- btn.Left := wnd.Width - 150 - 20;
- btn.Width := 150;
- btn.Top := 15;
- btn.Name := 'shop_admin';
- btn.OnClick.Subscribe(
- procedure
- begin
- SEND_RequestActiveBondConfig(true)
- end);
- btn.visible := false; // process_adminbutton
- shop_tutorial_area := TGUITutorialTipArea.Create(TIP_SHOP_PREMIUM, 0, 0, 0, 0, wnd);
- GUI3_ShopInventory := TShopInventory.Create(256 + 195 + 64, 0, wnd);
- // -------------------
- // FILTER SWITCH
- wnd := TGUIWindow.Create(oInterface);
- wnd.Name := 'window_shop_filter';
- wnd.SetSize(600, 10, 128 + 32, 256 + 128);
- wnd.AllowDocking := true;
- wnd.AllowResizing := false;
- wnd.visible := true;
- wnd.Left := 168;
- wnd.Top := 64 + 16;
- wnd.OnShow.Subscribe(UpdateFiltersTop);
- wnd.ShowBorder := false;
- wnd.CanBeActivated := false;
- ra := TGUIRenderArea.Create(0, 0, wnd.Width, wnd.Height, wnd);
- ra.RenderCallBack := window_shop_filter_Render;
- ra.center := false;
- L := 0;
- // FairShop
- btn := TGUIButton.Create(Common_Buttons3, wnd);
- btn.caption := GetTranslation('m1272');
- btn.Left := 8;
- btn.Top := 40 + 32 * L;
- btn.Width := 150;
- btn.Align := guiInUpperCorner;
- btn.OnClick.Subscribe(gui_stop_click_fair);
- btn.tag := 115;
- btn.reuse_delay := 60;
- btn.MouseTracerEnabled := true;
- btn.visible := true;
- Inc(L);
- // AutomaticAuction
- // Товары SC
- {shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('m402');
- shbtn.sidehint := GetTranslation('shop_hint_01');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_stop_click_automaticauction);
- shbtn.tag := 104;
- shbtn.reuse_delay := 60;
- shbtn.MouseTracerEnabled := true;
- shbtn.visible := true;
- Inc(L);
- }
- // Premium
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('m117');
- shbtn.sidehint := GetTranslation('shop_hint_02');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_stop_click_premium);
- shbtn.tag := 103;
- shbtn.reuse_delay := 60;
- shbtn.MouseTracerEnabled := true;
- Inc(L);
- // Weapons
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('h17c');
- shbtn.sidehint := GetTranslation('shop_hint_03');
- shbtn.Left := 8;
- shbtn.Width := 150;
- shbtn.Top := 40 + 32 * L;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_standartshopshow);
- shbtn.tag := 100;
- shbtn.reuse_delay := 60;
- shbtn.MouseTracerEnabled := true;
- Inc(L);
- // Armor
- // btn := TGUIButton.Create(Common_Buttons3, wnd);
- // btn.caption := GetTranslation('m103');
- // btn.Left := 8;
- // btn.Width := 150;
- // btn.Top := 40 + 32* L;
- // btn.Align := guiInUpperCorner;
- // btn.OnClick.Subscribe( gui_stop_click_armors;
- // btn.tag := 101;
- // btn.reuse_delay := 60;
- // Inc(L);
- // Acc
- // btn := TGUIButton.Create(Common_Buttons3, wnd);
- // btn.caption := GetTranslation('m104');
- // btn.Left := 8;
- // btn.Top := 40 + 32* L;
- // btn.Width := 150;
- // btn.Align := guiInUpperCorner;
- // btn.OnClick.Subscribe( gui_stop_click_accesories;
- // btn.tag := 102;
- // btn.reuse_delay := 60;
- // Inc(L);
- // Market
- { отключен в связи с хронической закрытостью рынка 29 мая 2014
- btn := TGUIButton.Create(Common_Buttons3, wnd);
- btn.MouseTracerEnabled := True;
- with btn do begin
- caption := GetTranslation('mn118');
- Left := 8;
- Top := 40 + 32* L;
- Width := 150;
- Align := guiInUpperCorner;
- OnClick.Subscribe( gui_stop_click_market;
- tag := 106;
- reuse_delay := 60;
- end;
- Inc(L);
- }
- // Rent
- {
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('mn117');
- shbtn.sidehint := GetTranslation('shop_hint_04');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_stop_click_rentshop);
- shbtn.tag := 105;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- }
- // Auction
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('m1255'); // GetTranslation('m712');
- shbtn.sidehint := GetTranslation('shop_hint_05');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_stop_click_players_auction);
- shbtn.tag := 112;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Dealers
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('m790');
- shbtn.sidehint := GetTranslation('shop_hint_06');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_stop_click_dealers);
- shbtn.tag := 109;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Mail
- // btn := TGUIButton.Create(Common_Buttons3, wnd);
- // btn.caption := GetTranslation('m817');
- // btn.Left := 8;
- // btn.Top := 40 + 32* L;
- // btn.Width := 150;
- // btn.Align := guiInUpperCorner;
- // btn.OnClick.Subscribe( gui_stop_click_mail;
- // btn.tag := 110;
- // btn.reuse_delay := 60;
- // btn.Visible := true;
- // Inc(L);
- // Quotation
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('m854');
- shbtn.sidehint := GetTranslation('shop_hint_07');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_stop_click_quotation);
- shbtn.tag := 111;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // SCBOX
- {shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('m1328');
- shbtn.sidehint := GetTranslation('shop_hint_08');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(gui_stop_click_scbox);
- shbtn.tag := 116;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L); }
- // Special Auction
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('spa016'); // GetTranslation('m712');
- shbtn.sidehint := GetTranslation('spa_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(ShowSpAuctionWindow);
- shbtn.tag := 118;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Gold Rush
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('art_boost_caption');
- shbtn.sidehint := GetTranslation('art_boost_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(ShowArtBoostWindow);
- shbtn.tag := 120;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Магазин ТС
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('trueskill_shop');
- shbtn.sidehint := GetTranslation('trueskill_shop_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- ShowMultiShop(7);
- end);
- shbtn.tag := 121;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Расходка
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('tcs_c08');
- shbtn.sidehint := GetTranslation('tcs_c08_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- GUI_ShowConsumableShop(15);
- end);
- shbtn.tag := 122;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Самир Рафи
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('coshop_1');
- shbtn.sidehint := GetTranslation('coshop_1_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- ShowMultiShop(1);
- end);
- shbtn.tag := 123;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Чаоксианг Ли
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('coshop_2');
- shbtn.sidehint := GetTranslation('coshop_2_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- ShowMultiShop(2);
- end);
- shbtn.tag := 124;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Иван Романов
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('coshop_3');
- shbtn.sidehint := GetTranslation('coshop_3_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- ShowMultiShop(3);
- end);
- shbtn.tag := 125;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Гордый Фримен
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('coshop_4');
- shbtn.sidehint := GetTranslation('coshop_4_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- ShowMultiShop(4);
- end);
- shbtn.tag := 126;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Лаборатория
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('coshop_5');
- shbtn.sidehint := GetTranslation('coshop_5_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- ShowMultiShop(5);
- end);
- shbtn.tag := 127;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- Inc(L);
- // Нужные вещи
- shbtn := TGUISideHintButton.Create(Common_Buttons3, wnd);
- shbtn.caption := GetTranslation('coshop_6');
- shbtn.sidehint := GetTranslation('coshop_6_hint');
- shbtn.Left := 8;
- shbtn.Top := 40 + 32 * L;
- shbtn.Width := 150;
- shbtn.Align := guiInUpperCorner;
- shbtn.OnClick.Subscribe(
- procedure
- begin
- ShowMultiShop(6);
- end);
- shbtn.tag := 128;
- shbtn.reuse_delay := 60;
- shbtn.visible := true;
- // Inc(L); // <-- don't forget to uncomment
- TGUITutorialTipArea.Create(TIP_LOC_SHOP_BUTTONS, 0, 0, 0, 0, wnd);
- // Обработка видимости в gui_Shop_Show
- // ---------------------------------------------------------------------
- // BANK WINDOW
- wnd := TGUIWindow.Create(oInterface);
- wnd.Name := 'window_bank';
- wnd.SetSize(10, 10, 530, 240);
- wnd.MinWidth := 1;
- wnd.MinHeight := 1;
- wnd.AllowDocking := true;
- wnd.AllowResizing := false;
- wnd.caption := GetTranslation('m106');
- wnd.visible := false;
- wnd.CenterOnScreen;
- wnd.CloseBtn.ModalResult := mrCancel;
- wnd.CloseBtn.visible := true;
- wnd.CloseBtn.OnClick.Subscribe(GS_SetGlobalPage_Map);
- with TGUIRenderArea.Create(260, 15, wnd.Width, wnd.Height, wnd) do
- begin
- RenderCallBack := RenderBankLogo;
- center := false;
- end;
- label1 := TGUILabel.Create(wnd);
- label1.Left := 16;
- label1.caption := Format(GetTranslation('ba01'), [inttostr(character.Credits)]);
- label1.Top := 29 + 16 * 9;
- label1.Name := 'cred_count';
- // label1.right_align := true;
- // goldcred_count
- label1 := TGUILabel.Create(wnd);
- label1.Left := 16;
- label1.caption := Format(GetTranslation('ba03'), [inttostr(character.GoldCredits)]);
- label1.Top := 29 + 16 * 10;
- label1.Name := 'goldcred_count';
- // label1.right_align := true;
- // BUYING
- label1 := TGUILabel.Create(wnd);
- label1.Left := 16;
- label1.caption := GetTranslation('ba04');
- label1.Top := 29;
- label1.Name := 'c';
- label1.Font := PIXELB;
- label1.color := TI_BOLD_COLOR;
- // Открывается в новом окне браузера
- label1 := TGUILabel.Create(wnd);
- label1.Left := 16;
- label1.caption := GetTranslation('ba08');
- label1.Top := 29 + 16 * 1;
- label1.Name := 'c';
- // Курс продажи
- label1 := TGUILabel.Create(wnd);
- label1.Left := 16;
- label1.caption := GetTranslation('ba02');
- label1.Top := 29 + 16 * 2;
- label1.Name := 'c2';
- label1.color := TI_COLOR;
- // Количество
- edit := TGUIEdit.Create(wnd);
- edit.Name := 'edit_buycred';
- edit.Left := 100;
- edit.Top := 32 + 16 * 5;
- edit.Width := 40;
- edit.Text := '30';
- edit.CursorPos := Length(edit.Text);
- edit.MaxLength := 6;
- edit.WorkMode := wmInteger;
- edit.visible := false;
- // BUY
- btn := TGUIButton.Create(Common_Buttons3, wnd);
- btn.caption := GetTranslation('m107');
- btn.Left := 6;
- btn.Top := wnd.Height - 39;
- btn.Width := 175;
- btn.Align := guiInUpperCorner;
- btn.OnClick.Subscribe(gui_shop_buy_cred);
- // CLOSE
- btn := TGUIButton.Create(Common_Buttons3, wnd);
- btn.caption := GetTranslation('mn19');
- btn.Top := wnd.Height - 39;
- btn.Width := 175;
- btn.Left := wnd.Width - btn.Width - 6;
- btn.Align := guiInUpperCorner;
- btn.OnClick.Subscribe(GS_SetGlobalPage_Map);
- // MAKE MONEY
- btn := TGUIButton.Create(Common_Buttons3, wnd);
- btn.caption := GetTranslation('m782');
- btn.Left := 6 + 175 + 3;
- btn.Top := wnd.Height - 39;
- btn.Width := 175;
- btn.Align := guiInUpperCorner;
- btn.OnClick.Subscribe(gui_shop_make_gold);
- btn.visible := AffiliateEarningGoldButtonEnabled;
- btn.visible := false;
- // ---------------------------------------------------------------------
- // BUY CONFIRM WINDOW
- end;
- // -----------------------------------------------------------------------------
- // -------------------------TGUIShop--------------------------------------------
- // -----------------------------------------------------------------------------
- constructor TGUIShop.Create(oLeft, oTop, oW, oH: integer; oParentControl: TGUIControl);
- begin
- inherited Create(oParentControl, oParentControl.fRootInterface);
- fWidth := oW;
- fHeight := oH;
- fBaseWidth := fWidth;
- fBaseHeight := fHeight;
- fLeft := oLeft;
- fTop := oTop;
- visible := true;
- Enabled := true;
- items := nil;
- SetLength(items, 0);
- fitemsHeight := 60;
- fCurIndex := -1;
- Loading := true;
- // fCurScroll:=0;
- // AllowSelect:=True;
- // Parse:=False;
- fCount := 1;
- filterindex := 0;
- TotalHeight := fBaseHeight;
- fTrkHeight := fHeight - 32;
- SetLength(items, 0);
- // scrollbar := TGUIScrollBar.Create(Oleft, oTop, 200, self);
- // fItemsHeight := 20;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoDraw;
- var
- i, _x, _y, AbsLeft, AbsTop: integer;
- ClientRect: TRect;
- Name: string;
- too_low_money: boolean;
- // alpha_dec : byte;
- procedure ScrollBar;
- begin
- DrawControlBorder(AbsLeft + Width - 16, AbsTop, 17, Height, TI_LINE_COLOR);
- DrawControlScrollBar(AbsLeft + Width - 14, AbsTop + 17 + fTrkTop, 12, fTrkHeight, Height - 36 = fTrkHeight);
- if not fUpPressed then
- Renderer_EffectCol(Common_Buttons, AbsLeft + Width - 16, AbsTop, AColor, 0, 0)
- else
- Renderer_EffectCol(Common_Buttons, AbsLeft + Width - 16, AbsTop, AColor, 1, 0);
- if not fDownPressed then
- Renderer_EffectCol(Common_Buttons, AbsLeft + Width - 16, AbsTop + Height - 16, AColor, 2, 0)
- else
- Renderer_EffectCol(Common_Buttons, AbsLeft + Width - 16, AbsTop + Height - 16, AColor, 3, 0);
- end;
- begin
- // Отрисовываем основную область
- AbsLeft := ParentControl.GetLeft + Left;
- AbsTop := ParentControl.GetTop + Top;
- ScrollBar;
- _x := 8;
- _y := -fCurScroll;
- ClientRect := Rect(AbsLeft, AbsTop + 2, AbsLeft + Width - 16, AbsTop + Height + 2);
- SetClipRect(ClientRect);
- for i := 0 to high(items) do
- begin
- if (_y >= -fitemsHeight) and (_y < Height) then
- begin
- if assigned(Common_TradeLot.texture) then
- begin
- if fCurIndex = i then
- Renderer_EffectCol(Common_TradeLot, AbsLeft + _x, AbsTop + _y, $77FFFFFF, 1, 0);
- Renderer_EffectCol(Common_TradeLot, AbsLeft + _x, AbsTop + _y, $FFFFFFFF, 0, 0);
- end;
- if assigned(Common_ItemSlot.texture) then
- Renderer_EffectCol(Common_ItemSlot, AbsLeft + _x + 10, AbsTop + _y + 14, $77FFFFFF, 0, 0);
- // if items[i].Equipped=1 then I_ICONS_MINI.Draw(AbsLeft + _x + IW - 11, AbsTop + _y + IH - 9, $FFFFFFFF, 0, I_ICONS_MINI.PatternWidth, I_ICONS_MINI.PatternHeight);
- // Renderer_Rectangle(AbsLeft + _x, AbsTop + _y, IW,IH, $0, $4400FF00, 2 or $100);
- // DrawControlBorder(AbsLeft + _x, AbsTop + _y , IW, IH, $FF00FFFF);
- // Font_TextOut(PIXEL, inttostr( items[i].item_id ), AbsLeft+_x, AbsTop+_y, $FFFFFFFF );
- too_low_money := false;
- if (items[i].price > 0) then
- begin
- too_low_money := character.Credits < items[i].price;
- end;
- if (items[i].GoldPrice > 0) then
- begin
- too_low_money := character.GoldCredits < items[i].GoldPrice;
- end;
- GameItem_Render(AbsLeft + _x + IW div 2 + 10, AbsTop + _y + IH div 2 + 14, items[i], tag = 0, false,
- ((tag = 23) or (items[i].count > 1)), false, true);
- if (items[i].available = 0) then
- begin
- Renderer_EffectCol(Common_TradeLot, AbsLeft + _x, AbsTop + _y, $FF222222, 1, 0);
- end;
- // hack for cash
- name := GetItemNameByID(items[i].item_id);
- if items[i].item_id <= 2 then
- name := inttostr(items[i].count) + ' ' + name;
- if (items[i].EnhanceLevel > 0) then
- begin
- Font_TextOut(PIXELB, '+' + inttostr(items[i].EnhanceLevel) + ' ', AbsLeft + _x + IW + 14,
- AbsTop + _y + 10, $FFFFFFFF - min(($1A1A00 * items[i].EnhanceLevel), $FFFF00) -
- (integer(too_low_money) * $B0000000));
- Font_TextOut(PIXELB, name, AbsLeft + _x + IW + 14 + Font_TextWidth(PIXELB,
- '+' + inttostr(items[i].EnhanceLevel) + ' '), AbsTop + _y + 10,
- TI_BOLD_COLOR - (integer(too_low_money) * $B0000000));
- end
- else
- begin
- Font_TextOut(PIXELB, name, AbsLeft + _x + IW + 14, AbsTop + _y + 10,
- TI_BOLD_COLOR - (integer(too_low_money) * $B0000000));
- end;
- if items[i].price > 0 then
- Font_TextOut(PIXEL, Format(GetTranslation('m105'), [IntThousandSeparation(inttostr(items[i].price))]),
- AbsLeft + _x + IW + 14, AbsTop + _y + 22, $FFFFFFFF - (integer(too_low_money) * $B0000000));
- if items[i].GoldPrice > 0 then
- Font_TextOut(PIXEL, Format(GetTranslation('m116'), [IntThousandSeparation(inttostr(items[i].GoldPrice))]),
- AbsLeft + _x + IW + 14, AbsTop + _y + 22, $FFFFFFFF - (integer(too_low_money) * $B0000000));
- if (items[i].available > 0) then
- begin
- Font_TextOut(PIXEL, Format(GetTranslation('m656'), [IntThousandSeparation(inttostr(items[i].available))]),
- AbsLeft + _x + IW + 14, AbsTop + _y + 36, $FFFFFFFF);
- end;
- end;
- Inc(_y, fitemsHeight);
- end;
- if Loading then
- begin
- Renderer_FillRect(Rect(AbsLeft + 10, AbsTop, Width - 26, Height + 6), $44000000, 0);
- Renderer_EffectCol(FindTexture('loading'), AbsLeft + Width div 2 - 16, AbsTop + Height div 2 - 16, $FFFFFFFF,
- (GTIME div 80) mod 16, 0);
- end;
- // DJXTextureList1.find('loading').Draw(AbsLeft + Width div 2 - 16, AbsTop + Height div 2 - 16, $FFFFFFFF, (GTIME div 80) mod 16, 32, 32 );
- ResetClipRect();
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoMouseDown(Button: TMouseButton; X, Y: integer);
- var { id, }
- i, _x, _y: integer;
- begin
- _x := 8;
- _y := -fCurScroll;
- if not Loading then
- for i := 0 to high(items) do
- begin
- if ((X - Left >= _x) and (X - Left <= _x + 266) and (Y - Top >= _y) and (Y - Top <= _y + fitemsHeight)) then
- begin
- if (items[i].available <> 0) then
- begin
- fCurIndex := i;
- end;
- end;
- Inc(_y, fitemsHeight);
- end;
- // if Assigned(OnSenderClick) then OnSenderClick(self);
- OnClick.Call;
- if (X > Left + Width - 16) and (X < Left + Width) and (Y < Top + 16) then
- fUpPressed := true;
- if (X > Left + Width - 16) and (X < Left + Width) and (Y > Top + Height - 16) then
- fDownPressed := true;
- if Length(items) > 0 then
- begin
- if (X > Left + Width - 16) and (X < Left + Width) and (Y > Top + 16 + fTrkTop) and
- (Y < Top + 16 + fTrkTop + fTrkHeight) then
- begin
- fScrollPressed := true;
- OldY := fTrkTop;
- MouseY := MainCursorY;
- end;
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoMouseDoubleClick(X, Y: integer);
- var
- i, _x, _y: integer;
- begin
- _x := 8;
- _y := -fCurScroll;
- if not Loading then
- for i := 0 to high(items) do
- begin
- if ((X - Left >= _x) and (X - Left <= _x + 256) and (Y - Top >= _y) and (Y - Top <= _y + fitemsHeight)) then
- begin
- if (items[i].available = 0) then
- begin
- Inc(_y, fitemsHeight);
- Continue;
- end;
- if (tag = 23) then
- begin
- SEND_RequestAssaultTeamItemManipulate(0, items[i].obj_id, 1);
- end
- else
- begin
- { if last_shop_type = 3 then
- SEND_RequestPremiumItemShopBuy( owner_id, items[i].obj_id, items[i].count) else
- SEND_RequestItemShopBuy( owner_id, items[i].obj_id, items[i].count, last_shop_type );
- cprint('sds ' + IntToStr(owner_id)); }
- gui_stop_buy();
- end;
- // SEND_RequestPremiumItemShopBuy( RenderCloseUpModel_soldier_id, items[i].obj_id, items[i].count) else
- // SEND_RequestItemShopBuy( RenderCloseUpModel_soldier_id, items[i].obj_id, items[i].count, last_shop_type );
- // cprint(IntTostr(owner_id) + ' vs. ' + IntTostr(RenderCloseUpModel_soldier_id));
- end;
- Inc(_y, fitemsHeight);
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoMouseWheelDown;
- begin
- fDownPressed := true;
- DoStep();
- fDownPressed := false;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoMouseWheelUp;
- begin
- fUpPressed := true;
- DoStep();
- fUpPressed := false;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoStep2(just_update: boolean);
- var
- fNewPos: integer;
- begin
- if (just_update) then
- begin
- fNewPos := fTrkTop;
- if fNewPos < 0 then
- fNewPos := 0;
- if fNewPos > (Height - 36 - fTrkHeight) then
- begin
- fNewPos := Height - 36 - fTrkHeight;
- fNewPos := Trunc((TotalHeight - (fHeight)) * (fNewPos / (Height - 36 - fTrkHeight)));
- fCurScroll := fNewPos;
- UpdateTrk;
- end;
- Exit;
- end;
- // if AllowFlip(fFlipScroll,5) then
- begin
- if fUpPressed then
- begin
- dec(fCurScroll, 25);
- if fCurScroll < 0 then
- fCurScroll := 0;
- UpdateTrk;
- end;
- if fDownPressed then
- begin
- if TotalHeight > fHeight then
- begin
- Inc(fCurScroll, 25);
- if fCurScroll > TotalHeight - (fHeight) then
- fCurScroll := TotalHeight - (fHeight);
- end;
- UpdateTrk;
- end;
- if fScrollPressed then
- begin
- fNewPos := OldY + (MainCursorY - MouseY);
- if fNewPos < 0 then
- fNewPos := 0;
- if fNewPos > (Height - 36 - fTrkHeight) then
- fNewPos := Height - 36 - fTrkHeight;
- fNewPos := Trunc((TotalHeight - (fHeight)) * (fNewPos / (Height - 36 - fTrkHeight)));
- fCurScroll := fNewPos;
- UpdateTrk;
- end;
- end;
- end;
- procedure TGUIShop.DoStep;
- begin
- DoStep2(false);
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoMouseUp(Button: TMouseButton; X, Y: integer);
- begin
- if Button = mbLeft then
- GUIN_DragItemExecute(self);
- fUpPressed := false;
- fDownPressed := false;
- fScrollPressed := false;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DeselectItem;
- begin
- fCurIndex := -1;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoCancelClick;
- begin
- fUpPressed := false;
- fDownPressed := false;
- fScrollPressed := false;
- // cprint('TGUIShop.DoCancelClick');
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.UpdateTrk;
- begin
- TotalHeight := high(items) * fitemsHeight + fitemsHeight;
- if TotalHeight <= Height then
- begin
- fTrkHeight := fHeight - 36;
- fTrkTop := 0;
- end
- else
- begin
- fTrkHeight := Round(Int((fHeight - 36) * ((fHeight) / (TotalHeight))));
- fTrkTop := Round((fHeight - 36 - fTrkHeight) * (fCurScroll / (TotalHeight - (fHeight))));
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.ScrollDown;
- begin
- // if fTextHeight<=fHeight-4 then fCurScroll:=0 else
- // fCurScroll:=fTextHeight-(fHeight-4);
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.Clear;
- begin
- fCurScroll := 0;
- fCurIndex := -1;
- // if Assigned(OnSenderClick) then OnSenderClick(self);
- OnClick.Call;
- SetLength(items, 0);
- end;
- // -----------------------------------------------------------------------------
- procedure TGUIShop.DoMouseMove(Button: TMouseButton; X, Y: integer);
- var
- i, _x, _y: integer;
- begin
- _x := 8;
- _y := -fCurScroll;
- // Common_ItemSlot.draw(AbsLeft + _x + 10, AbsTop + _y + 14, $77FFFFFF);
- for i := 0 to high(items) do
- begin
- if ((X - Left >= _x + 10) and (X - Left <= _x + IW + 5) and (Y - Top >= _y + 14 { - ih div 2 } ) and
- (Y - Top <= _y + IH + 14)) then
- begin
- Hint_WeaponHint_POP(items[i]);
- if (CurIndex <> -1) and (CurIndex = i) then
- begin
- if mbPressed[0] = 1 then
- if GUIInterface.guiDragMove = 1 then
- GUIN_DragItem(items[i], self);
- end;
- Exit;
- end;
- Inc(_y, fitemsHeight);
- end;
- end;
- // -----------------------------------------------------------------------------
- // TGUINewShopList
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.Clear(ForceClear: boolean = false);
- begin
- if (ShopItemType = itCustom) and not ForceClear then
- Exit;
- while fItemList.count > 0 do
- begin
- Dispose(fItemList[0]);
- fItemList.Delete(0);
- end;
- fItemIndex := -1;
- fMouseOverItem := -1;
- fMouseOverExpander := -1;
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_SortNameUp; cdecl;
- begin
- GUI3_ShopItemList.fItemList.Sort(TComparer<PGUIShopItem>.Construct(
- function(const Left, Right: PGUIShopItem): integer
- var
- nLeft, nRight: string;
- begin
- if (Left.Item.item_id <> 1) and (Right.Item.item_id = 1) then
- begin
- Exit(1);
- end;
- if (Left.Item.item_id = 1) then
- begin
- if (Right.Item.item_id = 1) then
- begin
- if (Left.Item.count > Right.Item.count) then
- Exit(1);
- if (Left.Item.count < Right.Item.count) then
- Exit(-1);
- Exit(0);
- end;
- Exit(-1);
- end;
- nLeft := GameItemDatas[Left.Item.GetItemIndex].Name;
- nRight := GameItemDatas[Right.Item.GetItemIndex].Name;
- Exit(-AnsiCompareStr(nLeft, nRight));
- end));
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_SortNameDown; cdecl;
- begin
- GUI3_ShopItemList.fItemList.Sort(TComparer<PGUIShopItem>.Construct(
- function(const Left, Right: PGUIShopItem): integer
- var
- nLeft, nRight: string;
- begin
- if (Left.Item.item_id <> 1) and (Right.Item.item_id = 1) then
- begin
- Exit(1);
- end;
- if (Left.Item.item_id = 1) then
- begin
- if (Right.Item.item_id = 1) then
- begin
- if (Left.Item.count > Right.Item.count) then
- Exit(1);
- if (Left.Item.count < Right.Item.count) then
- Exit(-1);
- Exit(0);
- end;
- Exit(-1);
- end;
- nLeft := GameItemDatas[Left.Item.GetItemIndex].Name;
- nRight := GameItemDatas[Right.Item.GetItemIndex].Name;
- Exit(AnsiCompareStr(nLeft, nRight));
- end));
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_SortSenderClick(Sender: TGUIControl); cdecl;
- var
- i: integer;
- ctrl: TGUIControl;
- begin
- if ((Sender as TTitleButton).ButtonState = tbsNone) or ((Sender as TTitleButton).ButtonState = tbsUp) then
- begin
- (Sender as TTitleButton).ButtonState := tbsDown;
- (Sender as TTitleButton).OnDown.Call; // CallBackDown();
- end
- else if (Sender as TTitleButton).ButtonState = tbsDown then
- begin
- (Sender as TTitleButton).ButtonState := tbsUp;
- (Sender as TTitleButton).OnUp.Call; // CallBackUp();
- end;
- ctrl := Sender.ParentControl;
- for i := 0 to ctrl.ControlsCount - 1 do
- if ctrl.controls[i] <> Sender then
- if ctrl.controls[i] is TTitleButton then
- (ctrl.controls[i] as TTitleButton).ButtonState := tbsNone;
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_SortPriceUp; cdecl;
- begin
- GUI3_ShopItemList.fItemList.Sort(TComparer<PGUIShopItem>.Construct(
- function(const Left, Right: PGUIShopItem): integer
- begin
- if (Left.Item.item_id <> 1) and (Right.Item.item_id = 1) then
- begin
- Exit(1);
- end;
- if (Left.Item.item_id = 1) then
- begin
- if (Right.Item.item_id = 1) then
- begin
- if (Left.Item.count > Right.Item.count) then
- Exit(1);
- if (Left.Item.count < Right.Item.count) then
- Exit(-1);
- Exit(0);
- end;
- Exit(-1);
- end;
- if (Left.Item.price <> 0) then
- begin
- if (Left.Item.price = Right.Item.price) then
- Exit(0)
- else if (Left.Item.price > Right.Item.price) then
- Exit(-1)
- else
- Exit(1);
- end
- else
- begin
- if (Left.Item.GoldPrice = Right.Item.GoldPrice) then
- Exit(0)
- else if (Left.Item.GoldPrice > Right.Item.GoldPrice) then
- Exit(-1)
- else
- Exit(1);
- end;
- end));
- end;
- // ------------------------------------------------------------------------------
- procedure Shop_SortPriceDown; cdecl;
- begin
- GUI3_ShopItemList.fItemList.Sort(TComparer<PGUIShopItem>.Construct(
- function(const Left, Right: PGUIShopItem): integer
- begin
- if (Left.Item.item_id <> 1) and (Right.Item.item_id = 1) then
- begin
- Exit(1);
- end;
- if (Left.Item.item_id = 1) then
- begin
- if (Right.Item.item_id = 1) then
- begin
- if (Left.Item.count > Right.Item.count) then
- Exit(1);
- if (Left.Item.count < Right.Item.count) then
- Exit(-1);
- Exit(0);
- end;
- Exit(-1);
- end;
- if (Left.Item.price <> 0) then
- begin
- if (Left.Item.price = Right.Item.price) then
- Exit(0)
- else if (Left.Item.price > Right.Item.price) then
- Exit(1)
- else
- Exit(-1);
- end
- else
- begin
- if (Left.Item.GoldPrice = Right.Item.GoldPrice) then
- Exit(0)
- else if (Left.Item.GoldPrice > Right.Item.GoldPrice) then
- Exit(1)
- else
- Exit(-1);
- end;
- end));
- end;
- // -----------------------------------------------------------------------------
- constructor TGUINewShopList.Create(oLeft, oTop, oWidth, oHeight: integer; oParentControl: TGUIControl);
- begin
- inherited Create(oParentControl, oParentControl.fRootInterface);
- fVisualMode := svmList;
- fLeft := oLeft;
- fTop := oTop;
- fWidth := oWidth;
- fHeight := oHeight;
- Loading := false;
- fItemHeight := 38;
- fItemIndex := -1;
- ClientBorder := TI_LINE_COLOR;
- fSB := TGUISmartScrollBar.Create(self, nil, nil, nil);
- fSB.Position := 0;
- fSB.WorkMode := wmDynamic;
- fSB.Left := fWidth - 16;
- // upgrade
- UpgradeTB := TTitleButton.Create(I_SC_TITLE, oParentControl);
- with TTitleButton(UpgradeTB) do
- begin
- Left := oLeft + 2;
- Top := oTop - 18 - 10 - 3;
- Width := 64 + 209;
- Height := 31;
- caption := GetTranslation('m537');
- OnUp.Subscribe(Shop_SortNameUp);
- OnDown.Subscribe(Shop_SortNameDown);
- OnClick.Subscribe(Shop_SortSenderClick);
- end;
- // price
- PriceTB := TTitleButton.Create(I_SC_TITLE, oParentControl);
- with TTitleButton(PriceTB) do
- begin
- Left := oLeft + 2 + 64 + 208 + 2;
- Top := oTop - 18 - 10 - 3;
- Width := 84;
- Height := 31;
- caption := GetTranslation('m248');
- OnUp.Subscribe(Shop_SortPriceUp);
- OnDown.Subscribe(Shop_SortPriceDown);
- OnClick.Subscribe(Shop_SortSenderClick);
- end;
- fItemList := TList<PGUIShopItem>.Create;
- fExpandedItemsList := TList<Cardinal>.Create;
- fAreaManager := TAreaEventManager.Create;
- fExpandPressed := 0;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.Deselect;
- begin
- fItemIndex := -1;
- end;
- // -----------------------------------------------------------------------------
- destructor TGUINewShopList.Destroy;
- begin
- while fItemList.count > 0 do
- begin
- Dispose(fItemList[0]);
- fItemList.Delete(0);
- end;
- fItemList.Free;
- fExpandedItemsList.Free;
- inherited;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DrawList(AbsLeft, AbsTop: integer);
- var
- i, _x, _y, W, h: integer;
- ratio: double;
- P: PGUIShopItem;
- ScrollWidth: integer;
- ClientRect: TRect;
- txt: string;
- color: Cardinal;
- shift: shortint;
- ItemHeight: integer;
- img: TDJXTexture;
- procedure DrawRegularItem;
- begin
- ItemHeight := fItemHeight;
- if (_y + ItemHeight < 0) or (_y > Height + 15) then
- begin
- Inc(_y, ItemHeight);
- Exit;
- end;
- _x := 3;
- if (fItemList.IndexOf(P) = fItemIndex) then
- begin
- Visual.Rect(AbsLeft + _x, AbsTop + _y, fWidth, ItemHeight, $77A7A7A7, $77A7A7A7, 0);
- end;
- if (P.count = 0) then
- begin
- Visual.Rect(AbsLeft + _x, AbsTop + _y, fWidth, ItemHeight, $220000FF, $220000FF, 0);
- end;
- Inc(_x, 3);
- // item icon
- if assigned(Common_ItemSlot.texture) then
- begin
- Renderer_EffectCol(Common_ItemSlot, AbsLeft + _x, AbsTop + _y + 2, $77FFFFFF, 0, 0);
- end;
- GameItem_Render(AbsLeft + _x + IW div 2, AbsTop + _y + 4 + IH div 2, P.Item, tag = 0, false,
- (tag = 23) or (P.Item.count > 1), true, true);
- fAreaManager.Add(AbsLeft + _x + IW div 2 - 32, AbsTop + _y + 4 + IH div 2 - 16, 64, 32, [i],
- procedure(params: array of variant)
- begin
- if fMouseOverItem >= 0 then
- Hint_WeaponHint_POP(fItemList[fMouseOverItem].Item);
- end);
- Inc(_x, 64 + 3);
- // item count
- shift := 0;
- if (P.Item.available > 0) then
- begin
- shift := 8;
- Visual.Text(Format(GetTranslation('m656'), [IntThousandSeparation(inttostr(P.Item.available))]), AbsLeft + _x,
- AbsTop + _y + 12 + shift, TI_COLOR, PIXEL, false);
- end;
- // item name
- Visual.Text(GameItemDatas[P.Item.GetItemIndex].Name, AbsLeft + _x, AbsTop + _y + 12 - shift, TI_COLOR,
- PIXEL, false);
- Inc(_x, 208);
- // item prices
- if (P.Item.price <> 0) or (P.Item.GoldPrice = High(Cardinal)) then
- begin
- if P.Item.price <> 0 then txt := IntThousandSeparation(inttostr(P.Item.price))
- else txt := 'FREE';
- // if (P.Item.EnhanceLevel < 20) then begin
- Visual.Text(txt, AbsLeft + _x, AbsTop + _y + 12, TI_COLOR, PIXEL, false);
- if(P.Item.price > 0) then begin
- if (P.cash_type > 2) then
- begin
- // Gui_window_Chat_ReceiveMessage(CHAT_ANY, 'DEBUG', '1. Item Id: ' + IntToStr(P.Item.Item_id) + ' cash type: ' + IntToStr(P.cash_type));
- img := GameItem_GetImage(P.cash_type);
- ratio := img.Width / img.Height;
- W := 32;
- H := Round(W / ratio);
- Visual.Draw(AbsLeft + _x + Visual.TextWidth(txt, PIXEL), AbsTop + _y + 12, W, H, img);
- end
- else
- begin
- // Gui_window_Chat_ReceiveMessage(CHAT_ANY, 'DEBUG', '2. Item Id: ' + IntToStr(P.Item.Item_id) + ' cash type: ' + IntToStr(P.cash_type));
- Visual.Draw(Common_Credits, AbsLeft + _x + Visual.TextWidth(txt, PIXEL), AbsTop + _y + 12, P.cash_type - 1);
- end;
- // end;
- end;
- fAreaManager.Add(AbsLeft + _x + Visual.TextWidth(txt, PIXEL), AbsTop + _y + 12, W, H, [P.cash_type],
- procedure(params: array of variant)
- begin
- CursorHint(GetItemNameByID(params[0]));
- end);
- end
- else
- begin
- txt := IntThousandSeparation(inttostr(P.Item.GoldPrice));
- Visual.Text(txt, AbsLeft + _x, AbsTop + _y + 12, TI_COLOR, PIXEL, false);
- Visual.Draw(Common_Credits, AbsLeft + _x + Visual.TextWidth(txt, PIXEL), AbsTop + _y + 12, 1);
- end;
- Inc(_x, 80 + 3);
- fAreaManager.Add(AbsLeft, AbsTop + _y, _x, ItemHeight, [i],
- procedure(params: array of variant)
- begin
- fMouseOverItem := params[0];
- end);
- Inc(_y, ItemHeight);
- Renderer_Line(AbsLeft, AbsTop + _y, AbsLeft + _x + 64, AbsTop + _y, DecAlphaEx2(TI_LINE_COLOR, $A0));
- end;
- // -----------------------------------------------------------------------
- var
- _y0: integer;
- begin
- inherited;
- // Отрисовываем основную область
- ScrollWidth := 15;
- // Draw grid
- Renderer_Rectangle(AbsLeft + 2, AbsTop, Width, Height, DisplaceRB(TI_LINE_COLOR), $00FFFFFF);
- Renderer_Rectangle(AbsLeft + 2, AbsTop - 32, Width, 33, DisplaceRB(TI_LINE_COLOR), $00FFFFFF);
- color := DecAlphaEx2(TI_LINE_COLOR, $A0);
- _x := 64 + 208 + 3;
- Renderer_Line(AbsLeft + _x, AbsTop - 32, AbsLeft + _x, AbsTop + Height - 2, color);
- // Рисуем фон
- ClientRect := Rect(AbsLeft, AbsTop + 2, AbsLeft + Width - ScrollWidth - 1, AbsTop + Height - 2);
- SetClipRect(ClientRect);
- _y := 3 - Trunc(fSB.Value);
- _y0 := _y;
- for i := 0 to fItemList.count - 1 do
- begin
- P := fItemList[i];
- if (not P.visible) then
- Continue;
- DrawRegularItem;
- end;
- if Loading then
- begin
- Renderer_FillRect(Rect(AbsLeft, AbsTop, Width - 18, Height + 6), $44000000, 0);
- Renderer_EffectCol(FindTexture('loading'), AbsLeft + Width div 2 - 16, AbsTop + Height div 2 - 16, $FFFFFFFF,
- (GTIME div 80) mod 16, 0);
- end;
- ResetClipRect();
- fSB.MaxValue := _y - _y0 - fHeight + 4;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DrawThumbs(AbsLeft, AbsTop: integer);
- const
- THUMB_WIDTH = 260;
- THUMB_HEIGHT = 250;
- MARGIN_X = 30;
- MARGIN_Y = 16;
- var
- i, _x, _y, _y0: integer;
- P: PGUIShopItem;
- ScrollWidth: integer;
- ClientRect: TRect;
- // color : Cardinal;
- cols, col: integer;
- procedure DrawItem;
- var
- c: Cardinal;
- DropIndex, j: integer;
- _xt, _yt { , _xl1, _xl2, _yl1, _yl2 } : integer;
- Premium: TPremiumDBItem;
- Hr: integer;
- SalePrice, price: integer;
- Percent: string;
- Opt: TRenderMoneyOptions;
- R: TRect;
- Time: integer;
- TimeText: string;
- // TotalDrops : integer;
- begin
- if i = fMouseOverItem then
- c := DecAlphaEx(TI_COLOR, $A0)
- else
- c := $80000000;
- if i = fItemIndex then
- c := DecAlphaEx(TI_COLOR, $60);
- c := DisplaceRB(c);
- Visual.Rect(AbsLeft + _x, AbsTop + _y, THUMB_WIDTH, THUMB_HEIGHT, $40000000, c, 0);
- // item icon
- if assigned(Common_ItemSlot.texture) then
- begin
- Renderer_EffectCol(Common_ItemSlot, AbsLeft + _x + 2, AbsTop + _y + 2, $77FFFFFF, 0, 0);
- end;
- fAreaManager.Add(AbsLeft + _x, AbsTop + _y, THUMB_WIDTH, THUMB_HEIGHT, [i],
- procedure(params: array of variant)
- begin
- fMouseOverItem := params[0];
- end);
- GameItem_Render(AbsLeft + _x + IW div 2 + 2, AbsTop + _y + 4 + IH div 2, P.Item, tag = 0, false, tag = 23,
- true, true);
- Visual.Text(P.Item.GetItemName, AbsLeft + _x + 70, AbsTop + _y + 32 - 14, TI_COLOR, NICE);
- fAreaManager.Add(AbsLeft + _x + IW div 2 - 32 + 2, AbsTop + _y + 4 + IH div 2 - 16, 64, 32, [i],
- procedure(params: array of variant)
- begin
- if { fMouseOverItem } params[0] > 0 then
- begin
- Hint_WeaponHint_POP(fItemList[params[0] { fMouseOverItem } ].Item);
- end;
- end);
- _yt := _y + 40;
- DropIndex := FindDropByName(GameItemDatas[P.Item.GetItemIndex].DropName);
- { if (DropIndex >= 0) then begin
- TotalDrops := length(DropLibrary[DropIndex].Items);
- if DropLibrary[DropIndex].PremiumID > 0 then inc(TotalDrops);
- end else begin
- TotalDrops := 0;
- end; }
- if (DropIndex >= 0) then
- begin
- for j := low(DropLibrary[DropIndex].items) to high(DropLibrary[DropIndex].items) do
- begin
- _xt := _x + 40;
- Visual.Text(DropLibrary[DropIndex].items[j].NameEnch, AbsLeft + _xt, AbsTop + _yt, TI_COLOR, PIXEL);
- _xt := _xt - 10 - Visual.TextWidth(inttostr(DropLibrary[DropIndex].items[j].count), PIXEL);
- Visual.Text(inttostr(DropLibrary[DropIndex].items[j].count) + 'x', AbsLeft + _xt, AbsTop + _yt,
- TI_COLOR, PIXEL);
- fAreaManager.Add(AbsLeft + _x, AbsTop + _yt, 40 + Visual.TextWidth(DropLibrary[DropIndex].items[j].NameEnch,
- PIXEL), 14, [DropLibrary[DropIndex].items[j].ItemID, DropLibrary[DropIndex].items[j].Enchance,
- DropLibrary[DropIndex].items[j].count],
- procedure(params: array of variant)
- var
- tmp: TItem;
- begin
- DefaultItem(tmp, params[0]);
- tmp.item_id := params[0];
- tmp.EnhanceLevel := params[1];
- tmp.count := params[2];
- Hint_WeaponHint_POP(tmp);
- end
- );
- Inc(_yt, 16);
- // if j >= 2 then break; {$MESSAGE WARN 'DO NOT FORGET TO REMOVE'}
- end;
- if DropLibrary[DropIndex].PremiumID > 0 then
- begin
- Premium := PremiumDataByID(DropLibrary[DropIndex].PremiumID);
- Hr := Premium.Hours; // ServicesGetValue(DropLibrary[DropIndex].PremiumID, 1);
- _xt := _x + 40;
- Visual.Text(GetTranslation('box_prem_text') + ' ' + Premium.Name, AbsLeft + _xt, AbsTop + _yt,
- TI_COLOR, PIXEL);
- _xt := _xt - 10 - Visual.TextWidth(inttostr(Hr), PIXEL);
- Visual.Text(inttostr(Hr) + GetTranslation('box_prem_unit'), AbsLeft + _xt, AbsTop + _yt, TI_COLOR, PIXEL);
- fAreaManager.Add(AbsLeft + _x, AbsTop + _yt, 40 + Visual.TextWidth(GetTranslation('box_prem_unit'), PIXEL),
- 14, [Premium.id],
- procedure(params: array of variant)
- var
- P: TPremiumAccount;
- pData: TPremiumDBItem;
- L: integer;
- begin
- P.id := params[0];
- P.EndTime := 0;
- P.EstimatedTime := 0;
- pData := PremiumDataByID(params[0]);
- L := 0;
- Hint_Clear;
- FillPremiumHint(P, pData, L);
- Hint_Pop;
- end
- );
- end;
- end;
- // item prices
- if (P.Item.price <> 0) then
- begin
- price := P.Item.NoDiscountPrice;
- SalePrice := P.Item.price;
- Opt := Opt + [rmoCredits];
- end
- else
- begin
- price := P.Item.NoDiscountPrice;
- SalePrice := P.Item.GoldPrice;
- Opt := Opt + [rmoGold];
- end;
- if SalePrice > price then
- begin
- Percent := '';
- end
- else if (price = 0) or (price = SalePrice) then
- begin
- Percent := '-0%'
- end
- else
- begin
- Percent := inttostr(Round(100 * SalePrice / price - 100)) + '%';
- end;
- if P.LimitedTime > 0 then
- begin
- Time := SecondsBetween(Date + sysutils.Time, UnixTimeToDateTime(P.LimitedTime));
- end
- else
- begin
- Time := -1;
- end;
- if Time > 0 then
- begin
- if Time <= 120 { s } then
- begin
- TimeText := inttostr(Time) + GetTranslation('time_unit_s')
- end
- else if Time <= 120 * 60 { min } then
- begin
- TimeText := inttostr(Time div 60) + GetTranslation('time_unit_m')
- end
- else if Time <= 48 * 60 * 60 { hr } then
- begin
- TimeText := inttostr(Time div 60 div 60) + GetTranslation('time_unit_h')
- end
- else
- begin
- TimeText := inttostr(Time div 60 div 60 div 24) + GetTranslation('time_unit_d')
- end;
- end;
- if { (TimeText > '') and (SalePrice < Price) } true then
- begin
- Visual.Rect(AbsLeft + _x + THUMB_WIDTH - 150,
- AbsTop + _y,
- { AbsLeft + _x + THUMB_WIDTH } 150,
- { AbsTop + _y + } THUMB_HEIGHT,
- $00000000,
- $4000FF00,
- $4000FF00,
- $0800FF00);
- end;
- _yt := _y + THUMB_HEIGHT - 16 * 2 - 8;
- // if TimeText > '' then _xt := _x + THUMB_WIDTH - 40 else _xt := _x + THUMB_WIDTH - 10;
- _xt := _x + THUMB_WIDTH - 10;
- if SalePrice < price then
- begin
- R := RenderMoney(AbsLeft + _xt, AbsTop + _yt, price, Opt + [rmoAlignRight], NICE, DecAlphaEx(TI_COLOR, $40));
- // Visual.Line( R.Left - 2, (R.Top + R.Bottom) div 2 - 3, R.Right + 2, (R.Top + R.Bottom) div 2 - 3, $FFFF0000 );
- Visual.Rect(R.Left - 2, (R.Top + R.Bottom) div 2 - 3, R.Right - R.Left + 4, 2, $FF0000FF, 0);
- end;
- Inc(_yt, 16);
- RenderMoney(AbsLeft + _xt, AbsTop + _yt, SalePrice, Opt + [rmoAlignRight], NICE, TI_COLOR);
- if (TimeText > '') then
- begin
- { _xt := _x + THUMB_WIDTH - 32 - 5;
- _yt := _y + THUMB_HEIGHT - 32 - 20; }
- if Percent = '' then
- begin
- _xt := _x + THUMB_WIDTH - 32 - 5;
- end
- else
- begin
- _xt := _x + THUMB_WIDTH - 10 - (32 + Visual.TextWidth(Percent, NICE)) div 2;
- end;
- _yt := _y + 25;
- Visual.Draw('icon_clock2', AbsLeft + _xt, AbsTop + _yt);
- _xt := _xt + 32 div 2;
- _yt := _yt + 32 + 6;
- Visual.Text(TimeText, AbsLeft + _xt, AbsTop + _yt, $FFFFFFFF, PIXEL, true);
- end;
- if SalePrice < price then
- begin
- _yt := _y + 5;
- _xt := _x + THUMB_WIDTH - 10 - Visual.TextWidth(Percent, NICE);
- Visual.Text(Percent, AbsLeft + _xt, AbsTop + _yt, TI_COLOR, NICE);
- end;
- end;
- // ---------------------------------------------------------------------
- begin
- inherited;
- // Отрисовываем основную область
- ScrollWidth := 15;
- // Draw grid
- Renderer_Rectangle(AbsLeft + 2, AbsTop, Width, Height, DisplaceRB(TI_LINE_COLOR), $00FFFFFF);
- // Renderer_Rectangle(AbsLeft + 2, AbsTop - 32, Width, 33, DisplaceRB(TI_LINE_COLOR), $00FFFFFF);
- // color := DecAlphaEx2(TI_LINE_COLOR, $A0);
- _x := 64 + 208 + 3;
- // Renderer_Line(AbsLeft + _x, AbsTop - 32, AbsLeft + _x, AbsTop + Height - 2, color);
- // Рисуем фон
- ClientRect := Rect(AbsLeft, AbsTop + 2, AbsLeft + Width - ScrollWidth - 1, AbsTop + Height - 2);
- SetClipRect(ClientRect);
- cols := (Width - ScrollWidth) div (THUMB_WIDTH + MARGIN_X);
- if cols < 1 then
- cols := 1;
- _y := 3 - Trunc(fSB.Value);
- _y0 := _y;
- col := cols + 1;
- _y := _y - THUMB_HEIGHT { - MARGIN_Y };
- for i := 0 to fItemList.count - 1 do
- begin
- if col > cols then
- begin
- _x := ((Width - ScrollWidth) - THUMB_WIDTH * cols - MARGIN_X * (cols - 1)) div 2;
- _y := _y + THUMB_HEIGHT + MARGIN_Y;
- col := 1;
- end;
- P := fItemList[i];
- if (not P.visible) then
- Continue;
- DrawItem;
- Inc(_x, THUMB_WIDTH + MARGIN_X);
- Inc(col);
- end;
- _y := _y + THUMB_HEIGHT + MARGIN_Y;
- if Loading then
- begin
- Renderer_FillRect(Rect(AbsLeft, AbsTop, Width - 18, Height + 6), $44000000, 0);
- Renderer_EffectCol(FindTexture('loading'), AbsLeft + Width div 2 - 16, AbsTop + Height div 2 - 16, $FFFFFFFF,
- (GTIME div 80) mod 16, 0);
- end;
- ResetClipRect();
- fSB.MaxValue := _y - _y0 - fHeight + 4;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DoDraw;
- var
- { i, _x, _y, } AbsLeft, AbsTop: integer;
- { P : PGUIShopItem;
- ScrollWidth: integer;
- ClientRect: TRect;
- txt : string;
- color : Cardinal;
- shift : shortint;
- ItemHeight : integer;
- Opt : TRenderMoneyOptions;
- Price, SalePrice : integer;
- Percent : string;
- Tex : TDJXTexture;
- Premium : TPremiumDBItem;
- procedure DrawDropItem;
- var
- j, DropIndex : integer;
- _y0, _yt, _xt, dx, dy : integer;
- pt : integer;
- Hr : integer;
- begin
- DropIndex := FindDropByName( GameItemDatas[P.Item.GetItemIndex].DropName );
- ItemHeight := fItemHeight + 25;
- if fExpandedItemsList.Contains(P.Item.Item_id) then
- if DropIndex >= 0 then begin
- ItemHeight := ItemHeight + length(DropLibrary[DropIndex].Items) * 16 + 4;
- if DropLibrary[DropIndex].PremiumID >= 0 then ItemHeight := ItemHeight + 16;
- end;
- if (_y + ItemHeight < 0) or (_y > Height + 15) then begin
- inc(_y, ItemHeight);
- Exit;
- end;
- _y0 := _y;
- _x := 3;
- if (fItemList.IndexOf(P) = fItemIndex) then begin
- Visual.Rect(AbsLeft + _x, AbsTop + _y, fWidth, ItemHeight, $77A7A7A7, $77A7A7A7, 0);
- end;
- inc(_x, 3);
- _yt := _y + 40;
- if fExpandedItemsList.Contains(P.Item.Item_id) then
- if (DropIndex >= 0) then begin
- for j := low(DropLibrary[DropIndex].Items) to high(DropLibrary[DropIndex].Items) do begin
- _xt := 70;
- Visual.Text(DropLibrary[DropIndex].Items[j].NameEnch, AbsLeft + _xt, AbsTop + _yt, TI_COLOR, PIXEL);
- _xt := 40 - Visual.TextWidth(IntToStr(DropLibrary[DropIndex].Items[j].Count), PIXEL);
- Visual.Text(IntToStr(DropLibrary[DropIndex].Items[j].Count) + 'x', AbsLeft + _xt, AbsTop + _yt, TI_COLOR, PIXEL);
- Inc(_yt, 16);
- end;
- if DropLibrary[DropIndex].PremiumID > 0 then begin
- Premium := PremiumDataByID(DropLibrary[DropIndex].PremiumID);
- Hr := Premium.Hours; //ServicesGetValue(DropLibrary[DropIndex].PremiumID, 1);
- _xt := 70;
- Visual.Text(GetTranslation('box_prem_text') + ' ' + Premium.Name, AbsLeft + _xt, AbsTop + _yt, TI_COLOR, PIXEL);
- _xt := 40 - Visual.TextWidth(IntToStr(Hr), PIXEL);
- Visual.Text(IntToStr(Hr) + GetTranslation('box_prem_unit'), AbsLeft + _xt, AbsTop + _yt, TI_COLOR, PIXEL);
- // Inc(_yt, 16);
- end;
- end;
- //item icon
- if assigned(Common_ItemSlot.texture) then begin
- Renderer_EffectCol(Common_ItemSlot, AbsLeft + _x, AbsTop + _y + 2, $77FFFFFF, 0, 0);
- end;
- GameItem_Render(AbsLeft + _x + IW div 2, AbsTop + _y + 4 + IH div 2, P.Item, tag = 0, false, tag = 23, true, true);
- fAreaManager.Add(AbsLeft + _x + IW div 2 - 32, AbsTop + _y + 4 + IH div 2 - 16, 64, 32, [i],
- procedure(params : array of variant)
- begin
- if fMouseOverItem >= 0 then Hint_WeaponHint_POP( fItemList[fMouseOverItem].Item );
- end);
- //item name
- Inc(_x, 64 + 3);
- Visual.Text( P.Item.GetItemName, AbsLeft + _x, AbsTop + _y + 12 - shift, TI_COLOR, PIXEL, false);
- Renderer_Line(AbsLeft, AbsTop + _y + 38, AbsLeft + _x + 203, AbsTop + _y + 38, DecAlphaEx2(TI_LINE_COLOR, $A0));
- Tex := FindTexture('sc_sort_btn');
- if fExpandedItemsList.Contains(P.Item.Item_id) then begin
- //Tex := FindTexture('btn_shift_u');
- if fMouseOverExpander = i then pt := 0 else pt := 1;
- end else begin
- //Tex := FindTexture('btn_shift_d');
- if fMouseOverExpander = i then pt := 2 else pt := 3;
- end;
- dx := 0; dy := 0;
- fAreaManager.DrawAndAdd(AbsLeft + 260 + dx, AbsTop + _y0 + 3 + dy, Tex, pt, [i],
- procedure(params : array of variant)
- begin
- fMouseOverExpander := params[0];
- end);
- _yt := _y0 + ItemHeight - 20;
- Renderer_Line(AbsLeft, AbsTop + _yt - 5, AbsLeft + _x + 203, AbsTop + _yt - 5, DecAlphaEx2(TI_LINE_COLOR, $A0));
- Inc(_x, 208);
- Opt := [];
- //item prices
- if (P.Item.Price <> 0) then begin
- Price := P.Item.NoDiscountPrice;
- SalePrice := P.Item.Price;
- Opt := Opt + [rmoCredits];
- end else begin
- Price := P.Item.NoDiscountPrice;
- SalePrice := P.Item.GoldPrice;
- Opt := Opt + [rmoGold];
- end;
- if (Price = 0) or (Price = SalePrice) then begin
- Percent := '-0%'
- end else begin
- Percent := IntToStr(100 * SalePrice div Price - 100) + '%';
- end;
- RenderMoney(AbsLeft + 30, AbsTop + _yt, Price, Opt, PIXEL, TI_COLOR);
- Visual.Text(Percent, AbsLeft + width div 2 - 20, AbsTop + _yt, TI_COLOR, PIXEL);
- RenderMoney(AbsLeft + _x, AbsTop + _yt, SalePrice, Opt, PIXEL, TI_COLOR);
- Visual.Line(AbsLeft + 100, AbsTop + _y0 + ItemHeight, AbsLeft + 100, AbsTop + _y0 + ItemHeight - 25, DecAlphaEx2(TI_LINE_COLOR, $A0));
- Inc(_x, 80 + 3);
- fAreaManager.Add(GetLeft, AbsTop + _y, _x, ItemHeight, [i],
- procedure(params : array of variant)
- begin
- fMouseOverItem := params[0];
- end);
- _y := _y0 + ItemHeight;
- Renderer_Line(AbsLeft, AbsTop + _y, AbsLeft + _x+64, AbsTop + _y, DecAlphaEx2(TI_LINE_COLOR, $A0));
- end;
- procedure DrawRegularItem;
- begin
- ItemHeight := fItemHeight;
- if (_y + ItemHeight < 0) or (_y > Height + 15) then begin
- inc(_y, ItemHeight);
- Exit;
- end;
- _x := 3;
- if (fItemList.IndexOf(P) = fItemIndex) then begin
- Visual.Rect(AbsLeft + _x, AbsTop + _y, fWidth, ItemHeight, $77A7A7A7, $77A7A7A7, 0);
- end;
- if (P.count = 0) then begin
- Visual.Rect(AbsLeft + _x, AbsTop + _y, fWidth, ItemHeight, $220000FF, $220000FF, 0);
- end;
- inc(_x, 3);
- //item icon
- if assigned(Common_ItemSlot.texture) then begin
- Renderer_EffectCol(Common_ItemSlot, AbsLeft + _x, AbsTop + _y + 2, $77FFFFFF, 0, 0);
- end;
- GameItem_Render(AbsLeft + _x + IW div 2, AbsTop + _y + 4 + IH div 2, P.Item, tag = 0, false, tag = 23, true, true);
- fAreaManager.Add(AbsLeft + _x + IW div 2 - 32, AbsTop + _y + 4 + IH div 2 - 16, 64, 32, [i],
- procedure(params : array of variant)
- begin
- if fMouseOverItem > 0 then Hint_WeaponHint_POP( fItemList[fMouseOverItem].Item );
- end);
- Inc(_x, 64 + 3);
- //item count
- shift := 0;
- if (P.Item.available > 0) then begin
- shift := 8;
- Visual.Text( Format(GetTranslation('m656'), [IntThousandSeparation(inttostr(P.Item.available))]), AbsLeft + _x, AbsTop + _y + 12 + shift, TI_COLOR, PIXEL, false);
- end;
- //item name
- Visual.Text( GameItemDatas[P.Item.GetItemIndex].name, AbsLeft + _x, AbsTop + _y + 12 - shift, TI_COLOR, PIXEL, false);
- Inc(_x, 208);
- //item prices
- if (P.Item.Price <> 0) then begin
- txt := IntThousandSeparation(IntToStr(P.Item.Price));
- if (not (P.Item.EnhanceLevel >= 20)) then begin
- Visual.Text( txt, AbsLeft + _x, AbsTop + _y + 12, TI_COLOR, PIXEL, false);
- Visual.Draw(Common_Credits, AbsLeft + _x + Visual.TextWidth(txt, PIXEL), AbsTop + _y + 12, 0);
- end;
- end else begin
- txt := IntThousandSeparation(IntToStr(P.Item.GoldPrice));
- if (P.Item.EnhanceLevel >= 20) then begin
- Visual.Text( txt, AbsLeft + _x, AbsTop + _y + 12, TI_COLOR, PIXEL, false);
- Visual.Draw(Common_Credits, AbsLeft + _x + Visual.TextWidth(txt, PIXEL), AbsTop + _y + 12, 1);
- end else begin
- Visual.Text( txt, AbsLeft + _x, AbsTop + _y + 12, TI_COLOR, PIXEL, false);
- Visual.Draw(Common_Credits, AbsLeft + _x + Visual.TextWidth(txt, PIXEL), AbsTop + _y + 12, 1);
- end;
- end;
- Inc(_x, 80 + 3);
- fAreaManager.Add(GetLeft, AbsTop + _y, _x, ItemHeight, [i],
- procedure(params : array of variant)
- begin
- fMouseOverItem := params[0];
- end);
- inc(_y, ItemHeight);
- Renderer_Line(AbsLeft, AbsTop + _y, AbsLeft + _x+64, AbsTop + _y, DecAlphaEx2(TI_LINE_COLOR, $A0));
- end;
- var
- _y0 : integer; }
- begin
- inherited;
- // Отрисовываем основную область
- AbsLeft := ParentControl.GetLeft + Left;
- AbsTop := ParentControl.GetTop + Top;
- case fVisualMode of
- svmList:
- DrawList(AbsLeft, AbsTop);
- svmThumbs:
- DrawThumbs(AbsLeft, AbsTop);
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DoMouseDoubleClick(X, Y: integer);
- begin
- if GTIME < fExpandPressed + 1000 then
- Exit;
- if (OnDoubleClick.Call) then
- begin
- Exit;
- end;
- gui_stop_buy;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DoMouseDown(Button: TMouseButton; X, Y: integer);
- // var
- // _y : Integer;
- // P : PGUIShopItem;
- // OldIndex : Integer;
- begin
- // _y := 3 - Trunc(fSB.Value);
- // OldIndex := fItemIndex;
- {
- fItemIndex := -1;
- if not Loading then
- for P in fItemList do begin
- if (not P.visible) then Continue;
- if (_y + fItemHeight < 0)or (_y > fHeight + 15) then begin
- inc(_y, fItemHeight);
- Continue;
- end;
- if (X > fLeft)and(X < fLeft + fWidth)and (Y >= fTop + _y)and(Y < fTop + _y + fItemHeight) then begin
- fItemIndex := fItemList.IndexOf(P);
- if (OldIndex <> fItemIndex) then begin
- shop_count_edt.Text := '1';
- shop_count_edt.CursorPos := Length(shop_count_edt.Text);
- shop_count_edt.SelectAll();
- end;
- break;
- end;
- inc(_y, fItemHeight);
- end;
- }
- if fMouseOverExpander >= 0 then
- begin
- if fExpandedItemsList.Contains(fItemList[fMouseOverExpander].Item.item_id) then
- begin
- fExpandedItemsList.Remove(fItemList[fMouseOverExpander].Item.item_id);
- end
- else
- begin
- fExpandedItemsList.Add(fItemList[fMouseOverExpander].Item.item_id);
- end;
- fExpandPressed := GTIME;
- end;
- if not Loading then
- begin
- if (fMouseOverItem > 0) and (fMouseOverItem <> fItemIndex) then
- begin
- shop_count_edt.Text := '1';
- shop_count_edt.CursorPos := Length(shop_count_edt.Text);
- shop_count_edt.SelectAll();
- end;
- fItemIndex := fMouseOverItem;
- end;
- end;
- procedure TGUINewShopList.DoMouseEnter;
- begin
- inherited;
- fMouseOverItem := -1;
- fMouseOverExpander := -1;
- end;
- procedure TGUINewShopList.DoMouseLeave;
- begin
- inherited;
- fMouseOverItem := -1;
- fMouseOverExpander := -1;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DoMouseMove(Button: TMouseButton; X, Y: integer);
- // var
- // _y : Integer;
- // P : PGUIShopItem;
- begin
- fMouseOverItem := -1;
- fMouseOverExpander := -1;
- fAreaManager.Process(MainCursorX, MainCursorY);
- fMx := X;
- fMy := Y;
- UpdateHint(fMx, fMy);
- // _y := 3 - Trunc(fSB.Value);
- if not Loading then
- { for P in fItemList do begin
- if (not P.visible) then Continue;
- if (_y + fItemHeight < 0)or (_y > fHeight + 15) then begin
- inc(_y, fItemHeight);
- Continue;
- end;
- if (X > fLeft)and(X < fLeft + fWidth)and (Y >= fTop + _y)and(Y < fTop + _y + fItemHeight) then begin
- if mbPressed[0]=1 then
- if GUIInterface.guiDragMove = 1 then
- GUIN_DragItem(fItemList.Items[fItemList.IndexOf(P)].Item, self );
- break;
- end;
- inc(_y, fItemHeight);
- end; }
- if (fMouseOverItem >= 0) and (fVisualMode <> svmThumbs) and (ShopItemType <> itCustom) then
- begin
- if mbPressed[0] = 1 then
- if GUIInterface.guiDragMove = 1 then
- GUIN_DragItem(fItemList.items[fMouseOverItem].Item, self);
- end;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DoMouseUp(Button: TMouseButton; X, Y: integer);
- begin
- if Button = mbLeft then
- GUIN_DragItemExecute(self);
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DoMouseWheelDown;
- begin
- fMouseOverItem := -1;
- fMouseOverExpander := -1;
- fSB.Value := fSB.Value + 20;
- DoStep();
- UpdateHint(fMx, fMy);
- fAreaManager.Process(MainCursorX, MainCursorY);
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.DoMouseWheelUp;
- begin
- fMouseOverItem := -1;
- fMouseOverExpander := -1;
- fSB.Value := fSB.Value - 20;
- DoStep();
- UpdateHint(fMx, fMy);
- fAreaManager.Process(MainCursorX, MainCursorY);
- end;
- function TGUINewShopList.GetSelectedItem: PGUIShopItem;
- begin
- if (fItemIndex >= 0) and (fItemIndex < fItemList.count) then
- Exit(fItemList.items[fItemIndex]);
- result := nil;
- end;
- // -----------------------------------------------------------------------------
- function TGUINewShopList.GetVisibleCount: Cardinal;
- var
- P: PGUIShopItem;
- begin
- if (fItemList.count = 0) then
- begin
- Exit(0);
- end;
- result := 0;
- for P in fItemList do
- if (P.visible) then
- begin
- Inc(result);
- end;
- end;
- procedure TGUINewShopList.SetVisualMode(const Value: TShopVisualMode);
- begin
- fVisualMode := Value;
- UpgradeTB.visible := Value = svmList;
- PriceTB.visible := Value = svmList;
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.UpdateHint(const X, Y: integer);
- { var
- _y: Integer;
- P : PGUIShopItem; }
- begin
- Exit;
- { _y := 3 - Trunc(fSB.Value);
- if not Loading then
- for P in fItemList do begin
- if (not P.visible) then Continue;
- if (_y + fItemHeight < 0)or (_y > fHeight + 15) then begin
- inc(_y, fItemHeight);
- Continue;
- end;
- if (X > fLeft)and(X < fLeft + fWidth)and
- (Y >= fTop + _y)and(Y < fTop + _y + fItemHeight) then begin
- if (X > fLeft)and(X < fLeft + 64 + 1) then begin
- Hint_WeaponHint_POP( P.Item );
- Exit;
- end;
- end;
- inc(_y, fItemHeight);
- end; }
- end;
- // -----------------------------------------------------------------------------
- procedure TGUINewShopList.UpdateTrk;
- begin
- // fSB.MaxValue := GetVisibleCount * fItemHeight - fHeight + 4;
- end;
- initialization
- finalization
- GUI3_ShopInventory.Free;
- end.
Add Comment
Please, Sign In to add comment