Hey,
da ich bei meinen einbauten von meinen Systemen immer wieder kleinigkeiten einfügen muss weil diese bei mir einfach schon Standart sind, hier n paar kleine und nützliche erweiterungen für manche UI Elemente.
Der Fix ist eher für Gauges / Fortschrittsbalken mit der AniImage klasse. Sobald die gescale'd wird sind die berechnungen fehlerhaft und 50% werden im Balken nicht als 50% angezeigt sondern irgendwas.
- // search
- int CGraphicImageInstance::GetWidth()
- {
- if (IsEmpty())
- return 0;
- return m_roImage->GetWidth();
- }
- int CGraphicImageInstance::GetHeight()
- {
- if (IsEmpty())
- return 0;
- return m_roImage->GetHeight();
- }
- // change like this
- int CGraphicImageInstance::GetWidth()
- {
- if (IsEmpty())
- return 0;
- return m_roImage->GetWidth() * m_v2Scale.x;
- }
- int CGraphicImageInstance::GetHeight()
- {
- if (IsEmpty())
- return 0;
- return m_roImage->GetHeight() * m_v2Scale.y;
- }
- # search
- def SetTextColor(self, color):
- if not self.ButtonText:
- return
- self.ButtonText.SetPackedFontColor(color)
- # add
- def SetOutline(self, Value=True):
- if not self.ButtonText:
- return
- self.ButtonText.SetOutline(Value)
- # search in "LoadElementButton"
- if value.has_key("text_color"):
- window.SetTextColor(value["text_color"])
- # add
- if value.has_key("text_outline"):
- if value["text_outline"]:
- window.SetOutline()
- # Search
- class RadioButton(Button):
- # add in this class
- def SetFontColor(self, color):
- if not self.ButtonText:
- return
- self.ButtonText.SetPackedFontColor(color)
- def SetOutline(self, Value=True):
- if not self.ButtonText:
- return
- self.ButtonText.SetOutline(Value)
- def SetFontName(self, fontName):
- if not self.ButtonText:
- return
- self.ButtonText.SetFontName(fontName)
Hier mal kurz in die locale/xx/locale_game.txt
und wieder ui.py
- #search in "LoadElementText"
- if value.has_key("fontsize"):
- # replace whole if statement
- if value.has_key("fontsize"):
- fontSize = value["fontsize"]
- if "SLARGE" == fontSize:
- window.SetFontName(localeInfo.UI_DEF_FONT_SLARGE)
- if "LARGE" == fontSize:
- window.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
- if "XLARGE" == fontSize:
- window.SetFontName(localeInfo.UI_DEF_FONT_XLARGE)
- if "XXLARGE" == fontSize:
- window.SetFontName(localeInfo.UI_DEF_FONT_XXLARGE)
- if "SMALL" == fontSize:
- window.SetFontName(localeInfo.UI_DEF_FONT_SMALL)
- # make this again in "LoadElementText" with "text_fontsize"
Das ist meine eigene klasse für ein anderes Scrollbar Design wie auf diesem Bild zu sehen:
Bitte melden Sie sich an, um dieses Bild zu sehen.
Die Klasse kommt ganz ohne Bild Elemente aus. Diese hat auch keine Hoch und Runter buttons, halt ein Flat design. Könnte man noch erweitern mit SetScrollBarColor oder sowas. Müsst ihr wissen
- # search
- class SmallThinScrollBar(ScrollBar):
- # add under this class
- class ScrollBarFlat(Window):
- SCROLLBAR_WIDTH = 11
- SCROLLBAR_MIDDLE_HEIGHT = 12
- MIDDLE_BAR_POS = 3
- MIDDLE_BAR_UPPER_PLACE = 0
- MIDDLE_BAR_DOWNER_PLACE = 4
- TEMP_SPACE = MIDDLE_BAR_UPPER_PLACE + MIDDLE_BAR_DOWNER_PLACE
- class MiddleBar(DragButton):
- def __init__(self):
- DragButton.__init__(self)
- self.AddFlag("movable")
- #self.AddFlag("restrict_x")
- def MakeScrollBar(self):
- self.scrollbar = Bar()
- self.scrollbar.SetParent(self)
- self.scrollbar.SetColor(0xFF6B655A)
- self.scrollbar.SetPosition(3, 3)
- self.scrollbar.SetSize(5, 10)
- self.scrollbar.AddFlag("not_pick")
- self.scrollbar.Show()
- def SetSize(self, height):
- height = max(12, height)
- self.scrollbar.SetSize(5, height)
- DragButton.SetSize(self, 8, height)
- #height -= 4*3
- #self.middle.SetRenderingRect(0, 0, 0, float(height)/4.0)
- def __init__(self):
- Window.__init__(self)
- self.pageSize = 1
- self.curPos = 0.0
- self.eventScroll = lambda *arg: None
- self.lockFlag = False
- self.scrollStep1 = 0.20
- self.scrollStep2 = 0.10
- self.CreateScrollBar()
- def __del__(self):
- Window.__del__(self)
- def CreateScrollBar(self):
- self.barSlotOutline = Bar()
- self.barSlotOutline.SetParent(self)
- self.barSlotOutline.SetSize(11, 50)
- self.barSlotOutline.SetPosition(0, 0)
- self.barSlotOutline.SetColor(0xFF000000)
- self.barSlotOutline.AddFlag("not_pick")
- self.barSlotOutline.Show()
- self.barSlotEdge = Bar()
- self.barSlotEdge.SetParent(self.barSlotOutline)
- self.barSlotEdge.SetSize(9, 48)
- self.barSlotEdge.SetPosition(1, 1)
- self.barSlotEdge.SetColor(0xFF6B655A)
- self.barSlotEdge.AddFlag("not_pick")
- self.barSlotEdge.Show()
- self.barSlotMiddle = Bar()
- self.barSlotMiddle.SetParent(self.barSlotOutline)
- self.barSlotMiddle.SetSize(7, 46)
- self.barSlotMiddle.SetPosition(2, 2)
- self.barSlotMiddle.SetColor(0xFF0C0C0C)
- self.barSlotMiddle.AddFlag("not_pick")
- self.barSlotMiddle.Show()
- self.middleBar = self.MiddleBar()
- self.middleBar.SetParent(self)
- self.middleBar.SetMoveEvent(__mem_func__(self.OnMove))
- self.middleBar.MakeScrollBar()
- self.middleBar.SetSize(12)
- self.middleBar.Show()
- self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
- def Destroy(self):
- self.middleBar = None
- #self.upButton = None
- #self.downButton = None
- self.eventScroll = lambda *arg: None
- def SetScrollEvent(self, event):
- self.eventScroll = event
- def SetMiddleBarSize(self, pageScale):
- realHeight = self.GetHeight()
- self.SCROLLBAR_MIDDLE_HEIGHT = int(pageScale * float(realHeight))
- self.middleBar.SetSize(self.SCROLLBAR_MIDDLE_HEIGHT)
- self.pageSize = self.GetHeight() - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
- def SetScrollBarSize(self, height):
- self.pageSize = height - self.SCROLLBAR_MIDDLE_HEIGHT - self.TEMP_SPACE
- self.SetSize(11, height)
- self.middleBar.SetRestrictMovementArea(self.MIDDLE_BAR_POS, self.MIDDLE_BAR_UPPER_PLACE, self.MIDDLE_BAR_POS, height - self.TEMP_SPACE)
- self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
- self.UpdateBarSlot()
- def UpdateBarSlot(self):
- self.barSlotOutline.SetSize(11, self.GetHeight() + 1)
- self.barSlotEdge.SetSize(9, self.barSlotOutline.GetHeight() - 2 + 1)
- self.barSlotMiddle.SetSize(7, self.barSlotOutline.GetHeight() - 4 + 1)
- def GetPos(self):
- return self.curPos
- def SetPos(self, pos):
- pos = max(0.0, pos)
- pos = min(1.0, pos)
- newPos = float(self.pageSize) * pos
- self.middleBar.SetPosition(self.MIDDLE_BAR_POS, int(newPos) + self.MIDDLE_BAR_UPPER_PLACE)
- self.OnMove()
- def SetScrollStep(self, step):
- self.scrollStep1 = step
- def GetScrollStep(self):
- return self.scrollStep1
- def OnUp(self):
- self.SetPos(self.curPos-self.scrollStep1)
- def OnDown(self):
- self.SetPos(self.curPos+self.scrollStep1)
- def OnUp2(self):
- self.SetPos(self.curPos-self.scrollStep2)
- def OnDown2(self):
- self.SetPos(self.curPos+self.scrollStep2)
- def OnMove(self):
- if self.lockFlag:
- return
- if 0 == self.pageSize:
- return
- (xLocal, yLocal) = self.middleBar.GetLocalPosition()
- self.curPos = float(yLocal - self.MIDDLE_BAR_UPPER_PLACE) / float(self.pageSize)
- self.eventScroll()
- def OnMouseLeftButtonDown(self):
- (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
- #pickedPos = yMouseLocalPosition
- pickedPos = yMouseLocalPosition
- newPos = float(pickedPos) / float(self.pageSize)
- self.SetPos(newPos)
- def LockScroll(self):
- self.lockFlag = True
- def UnlockScroll(self):
- self.lockFlag = False
- # search
- elif Type == "small_thin_scrollbar":
- parent.Children[Index] = SmallThinScrollBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
- # add
- elif Type == "scrollbar_flat":
- parent.Children[Index] = ScrollBarFlat()
- parent.Children[Index].SetParent(parent)
- self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
Das wars erstmal, villeicht fällt mir irgenwann noch mehr ein was ich noch drinne hab oder ich mal neu hinzufüge weil ichs gerad brauche
Nundenn, viel spaß!