def ReloadItemsList(): global ListItems global SelectedItemLevel global LastClickedItem global SelectedItemPrice global SelectedItemID ListItems = gameObjs.VerticalListWithDescription( pygame.Rect(0, 0, 350, 250)) ListItems.ClearItems() print("ReloadItemsList : Add Store Items") for x in range(gameMain.DefaultCnt.Get_RegKey("/ItemData/minimum", int), gameMain.DefaultCnt.Get_RegKey("/ItemData/all", int) + 1): # -- Check if item is Visible -- # if gameMain.DefaultCnt.Get_RegKey("/ItemData/" + str(x) + "/is_upgradeable"): # -- Reg Keys Locations -- # CurrentItemRoot = "/ItemData/upgrade/" + str(x) + "_" CurrentItemLevel = gameItems.GetItemLevel_ByID(x) + 1 CurrentItemSprite = gameItems.GetItemSprite_ByID(x) CurrentItemDescription = CurrentItemRoot + "description_" + str( CurrentItemLevel) CurrentItemName = CurrentItemRoot + "name_" + str(CurrentItemLevel) print("ReloadItemsList : CurrentItem[" + CurrentItemRoot + "]") ListItems.AddItem( gameMain.DefaultCnt.Get_RegKey(CurrentItemName), gameMain.DefaultCnt.Get_RegKey(CurrentItemDescription), gameMain.DefaultCnt.Get_RegKey(CurrentItemSprite)) print("ReloadItemsList : Add Store Items") RestartAnimation()
def Run(): global DeltaTime DeltaTime += 1 if DeltaTime > 2: DeltaTime = 0 # -- ItemID is 0 ItemLevel = items.GetItemLevel_ByID(0) ItemClickPerSecound = gameMain.DefaultCnt.Get_RegKey( "/ItemData/0/lv_{0}_click".format(ItemLevel), float) TotalValue = ( ItemClickPerSecound * gameMain.save.Current_MoneyMultiplier) * items.GetItemCount_ByID(0) AdderText = "+{0}".format(utils.FormatNumber(TotalValue)) try: # -- Items exists -- # Index = gameMain.ScreenGame.IncomingLog.TextGrind_Text.index( AdderText) gameMain.save.Current_Money += TotalValue except ValueError: # -- Item Does not Exist -- # gameMain.ScreenGame.IncomingLog.AddMessageText( AdderText, True, (150, 220, 150), TotalValue)
def Render(DISPLAY): global WindowObject global DrawnSurface global BuyButton global ListItems global DownBar_BuyPanelAnimEnabled global DownBar_BuyPanelYOffset global LastClickedItem global SelectedItemID global SelectedItemPrice global SelectedItemLevel global StoreLocked # -- Update the Surface -- # DrawnSurface = pygame.Surface((WindowObject.WindowSurface_Rect[2], WindowObject.WindowSurface_Rect[3]), pygame.SRCALPHA) if not StoreLocked: # -- Draw the List -- # ListItems.Render(DrawnSurface) # -- Render the Selected Item Text -- # if ListItems.LastItemClicked != "null": if LastClickedItem != ListItems.LastItemClicked: DownBar_BuyPanelAnimEnabled = True DownBar_BuyPanelYOffset = 0 LastClickedItem = ListItems.LastItemClicked # -- Set Item Price and ID -- # SelectedItemID = ListItems.LastItemOrderID - 1 SelectedItemLevel = gameItems.GetItemLevel_ByID(SelectedItemID) + 1 SelectedItemPrice = gameItems.GetItemUpgradePrice_ByID( SelectedItemID) # -- Down Panel Background -- # CONTENT_MANAGER.Shape_Rectangle( DrawnSurface, (0, 0, 0, 100), (0, DrawnSurface.get_height() - DownBar_BuyPanelYOffset, DrawnSurface.get_width(), DownBar_BuyPanelYOffset)) CONTENT_MANAGER.Shape_Rectangle( DrawnSurface, (16, 166, 152), (0, DrawnSurface.get_height() - DownBar_BuyPanelYOffset - 1, DrawnSurface.get_width(), 1)) # -- Draw the Buy Button -- # BuyButton.Render(DrawnSurface) # -- Draw the Item Title -- # CONTENT_MANAGER.FontRender( DrawnSurface, "/PressStart2P.ttf", 15, ListItems.LastItemClicked, (250, 250, 250), 10, DrawnSurface.get_height() - DownBar_BuyPanelYOffset + 5, gameMain.DefaultCnt.Get_RegKey("/OPTIONS/font_aa")) # -- Draw the Item Price -- # PriceTextOpacity = 255 if save.Current_Experience < SelectedItemPrice: PriceTextOpacity = 100 - abs(save.Current_Experience - SelectedItemPrice) if PriceTextOpacity <= 100: PriceTextOpacity = 100 CONTENT_MANAGER.FontRender( DrawnSurface, "/PressStart2P.ttf", 8, "€xp" + str(utils.FormatNumber(SelectedItemPrice)), (PriceTextOpacity, PriceTextOpacity, PriceTextOpacity), 10, DrawnSurface.get_height() - DownBar_BuyPanelYOffset + 20, gameMain.DefaultCnt.Get_RegKey("/OPTIONS/font_aa"), Opacity=PriceTextOpacity) WindowObject.Render(DISPLAY) # -- Render Window Border DISPLAY.blit( DrawnSurface, (WindowObject.WindowSurface_Rect[0], WindowObject.WindowSurface_Rect[1])) # -- Render Window Objects
def GetNextLevelByID(ItemID): CurrentLevel = gameItems.GetItemLevel_ByID(ItemID) CurrentLevel += 1 return CurrentLevel
def Render(self, DISPLAY): # -- Recreate Surface -- # self.ListSurface = pygame.Surface((self.Rectangle[2], self.Rectangle[3]), pygame.SRCALPHA) mainScript.shape.Shape_Rectangle(DISPLAY, (0, 12, 30), (self.Rectangle[0], self.Rectangle[1] - 16, self.Rectangle[2], 16), 0, 0, 2, 2) mainScript.DefaultCnt.FontRender(DISPLAY, "/PressStart2P.ttf", 10, mainScript.DefaultCnt.Get_RegKey("/strings/game/game_items_view"), (255, 255, 255), self.Rectangle[0] + self.Rectangle[2] / 2 - mainScript.DefaultCnt.GetFont_width("/PressStart2P.ttf", 10, mainScript.DefaultCnt.Get_RegKey("/strings/game/game_items_view")) / 2, self.Rectangle[1] - 13) Draw_Panel(DISPLAY, self.Rectangle) for i, itemID in enumerate(self.ItemsID): ItemName = mainScript.DefaultCnt.Get_RegKey("/ItemData/name/" + str(itemID)) ItemWidth = 156 ItemX = self.ScrollX + ItemWidth * i ItemRect = (ItemX, self.Rectangle[3] / 2 - 90 / 2, ItemWidth - 5, 90) # -- Draw the Background -- # Draw_Panel(self.ListSurface, ItemRect, True) # -- Render the Item Title -- # mainScript.DefaultCnt.FontRender(self.ListSurface, "/PressStart2P.ttf", 9, ItemName, (250, 250, 250), ItemRect[0] + ItemRect[2] / 2 - mainScript.DefaultCnt.GetFont_width("/PressStart2P.ttf", 9, ItemName) / 2, ItemRect[1] + 2, mainScript.DefaultCnt.Get_RegKey("/OPTIONS/font_aa")) # -- Render the Item Sprite -- # mainScript.DefaultCnt.ImageRender(self.ListSurface, mainScript.DefaultCnt.Get_RegKey(gameItems.GetItemSprite_ByID(int(itemID))), ItemRect[0] + 3, ItemRect[1] + 15, 64, 64, mainScript.DefaultCnt.Get_RegKey("/OPTIONS/sprite_aa")) # -- Render the Item Info -- # LittleInfoText = mainScript.DefaultCnt.Get_RegKey("/strings/game/items_info").format(utils.FormatNumber(gameItems.GetItemCount_ByID(self.ItemsID[i])).replace(".00", ""), str(gameItems.GetItemLevel_ByID(self.ItemsID[i]))) # -- Render Item Info -- # mainScript.DefaultCnt.FontRender(self.ListSurface, "/PressStart2P.ttf", 10, LittleInfoText, (250, 250, 250), ItemRect[0] + 70, ItemRect[1] + 12, mainScript.DefaultCnt.Get_RegKey("/OPTIONS/font_aa")) DISPLAY.blit(self.ListSurface, (self.Rectangle[0], self.Rectangle[1]))