Grzyb 12 Posted November 5 Share Posted November 5 (edited) I did a job for someone once, and when I saw Mali's code from 2020, I was stunned by how many unnecessary packets and lines of code it sends. locale_game.txt NEW_KOMUNIKAT1 Testowy Komunikat Jeden NEW_KOMUNIKAT2 Testowy Komunikat Dwa NEW_KOMUNIKAT3 Testowy Komunikat Trzy NEW_KOMUNIKAT4 Testowy Komunikat Cztery NEW_KOMUNIKAT5 Testowy Komunikat Piec NEW_KOMUNIKAT6 Testowy Komunikat Szesc ui.py class MiddleBoard(Window): CORNER_WIDTH = 16 CORNER_HEIGHT = 16 LINE_WIDTH = 16 LINE_HEIGHT = 16 LT = 0 LB = 1 RT = 2 RB = 3 L = 0 R = 1 T = 2 B = 3 def __init__(self, layer = "UI"): Window.__init__(self, layer) CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ] LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ] Base = ExpandedImageBox() Base.AddFlag("not_pick") Base.LoadImage("d:/ymir work/ui/cien.png") Base.SetParent(self) Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT) Base.Show() self.Base = Base self.Corners = [] for fileName in CornerFileNames: Corner = ExpandedImageBox() Corner.AddFlag("attach") Corner.AddFlag("not_pick") Corner.LoadImage(fileName) Corner.SetParent(self) Corner.SetPosition(0, 0) Corner.Show() self.Corners.append(Corner) self.Lines = [] for fileName in LineFileNames: Line = ExpandedImageBox() Line.AddFlag("attach") Line.AddFlag("not_pick") Line.LoadImage(fileName) Line.SetParent(self) Line.SetPosition(0, 0) Line.Show() self.Lines.append(Line) self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT) self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0) def __del__(self): Window.__del__(self) def SetSize(self, width, height): width = max(self.CORNER_WIDTH*2, width) height = max(self.CORNER_HEIGHT*2, height) Window.SetSize(self, width, height) self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT) self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0) self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT) self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT) self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT) verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage) self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage) self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0) self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0) if self.Base: self.Base.SetRenderingRect(0, 0, (float(width)-32)/float(self.Base.GetWidth()) - 1.0, (float(height)-32)/float(self.Base.GetHeight()) - 1.0) def ShowInternal(self): self.Base.Show() for wnd in self.Lines: wnd.Show() for wnd in self.Corners: wnd.Show() def HideInternal(self): self.Base.Hide() for wnd in self.Lines: wnd.Hide() for wnd in self.Corners: wnd.Hide() and elif Type == "middleboard": parent.Children[Index] = MiddleBoard() parent.Children[Index].SetParent(parent) self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent) introloading.py add import: import background import random Find: self.loadingGage=self.GetChild("FullGage") add after: self.loadingTip2=self.GetChild("LoadingTip") Find: def LoadData(self, playerX, playerY): and add: def LoadData(self, playerX, playerY): grzybovh = [ localeInfo.NEW_KOMUNIKAT1, localeInfo.NEW_KOMUNIKAT2, ] grzybovh2 = [ localeInfo.NEW_KOMUNIKAT3, localeInfo.NEW_KOMUNIKAT4, ] grzybovh3 = [ localeInfo.NEW_KOMUNIKAT5, localeInfo.NEW_KOMUNIKAT6, ] #Here you can add any maps, names from atlasinfo if background.GetCurrentMapName() == "metin2_map_a1": self.loadingTip2.SetText(random.choice(grzybovh)) elif background.GetCurrentMapName() == "metin2_map_c1": self.loadingTip2.SetText(random.choice(grzybovh2)) else: self.loadingTip2.SetText(random.choice(grzybovh3)) uiscript/introloading.py { "name": "TipBackground", "type": "middleboard", "x": float(SCREEN_WIDTH) / 2 - (SCREEN_WIDTH / 4), "y": float(SCREEN_HEIGHT) * 500 / 600.0 - 50, "width": SCREEN_WIDTH / 2, "height": 50, "children": [ { "name": "LoadingTip", "type": "text", "x": float(SCREEN_WIDTH) / 4, "y": 16, "text": " ", "text_horizontal_align": "center", "fontsize": "LARGE", }, ], }, Edited November 5 by Metin2 Dev International Core X - External 2 Internal 2 Ymir Work Metin2 Code in Nutshell Link to comment Share on other sites More sharing options...
m2hosting 0 Posted November 14 Share Posted November 14 Base.LoadImage("d:/ymir work/ui/cien.png") ??? Link to comment Share on other sites More sharing options...
Recommended Posts