Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## #UNTESTED# Only for python 2.6 and higher
- ## If you want to use this with lower python version you have to replace
- ## the str.format conversion to "%" with their right syntax
- ## Line 6 is the first line of the uiStatusUp.py file
- ## Line 73 is the first line of the StatusUpWindow.py file
- import ui
- import player
- import m2net#net!!
- import wndMgr
- class StatusUp(ui.ScriptWindow):
- MAXSTAT = 90
- def __init__(self):
- ui.ScriptWindow.__init__(self)
- self.editLineDict = {}
- self.valueDict = {}
- self.gaugeDict = {}
- self.Keys = {
- "HTH" : "ht",
- "INT" : "iq",
- "STR" : "st",
- "DEX" : "dx",
- }
- self.__LoadWindow()
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def OnPressEscapeKey(self):
- self.Hide()
- return True
- def Destroy(self):
- self.ClearDictionary()
- def __LoadWindow(self):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, "UIScript/StatusUpWindow.py")
- except:
- import exception
- exception.Abort("StatusUp.LoadWindow.LoadObject")
- try:
- self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Hide))
- for key, val in self.Keys.iteritems():
- self.editLineDict[val] = self.GetChild("{0}_Add".format(key))
- self.valueDict[val] = self.GetChild("{0}_Value".format(key))
- self.gaugeDict[val] = self.GetChild("{0}_Gauge".format(key))
- self.GetChild("{0}_Plus".format(key)).SetEvent(lambda stat=val: self.AddStat(stat))
- except:
- import exception
- exception.Abort("StatusUp.LoadWindow.BindObject")
- def OnUpdate(self):
- for key, val in self.Keys.iteritems():
- tmp = player.GetStatus(eval("player.{0}".format(val.upper())))
- self.valueDict[val].SetText("{0}/{1}".format(tmp, self.MAXSTAT))
- self.gaugeDict[val].SetPercentage(tmp, self.MAXSTAT)
- def AddStat(self, stat):
- points = int(self.editLineDict[stat].GetText())
- if player.GetStatus(player.STAT) >= points:
- m2net.SendChatPacket("/stat {0} {1}".format(stat, points))#net
- #else:
- # chat.AppendChat(1, "Fuck off, idiot.")
- #
- ###
- #
- BOARD_HEIGHT = 250
- BOARD_WIDTH = 250
- ROOT_PATH = "d:/ymir work/ui/game/windows/"
- SMALL_VALUE_FILE = "d:/ymir work/ui/public/Parameter_Slot_00.sub"
- window = {
- "name" : "StatusupWindow",
- "x" : (SCREEN_WIDTH / 2) - (BOARD_WIDTH / 2),
- "y" : (SCREEN_HEIGHT / 2) - (BOARD_HEIGHT / 2),
- "style" : ("movable", "float",),
- "width" : BOARD_WIDTH,
- "height" : BOARD_HEIGHT,
- "children" :
- (
- {
- "name" : "board",
- "type" : "board",
- "x" : 0,
- "y" : 0,
- "width" : BOARD_WIDTH,
- "height" : BOARD_HEIGHT,
- "children" :
- (
- ## Titlebar
- {
- "name" : "TitleBar",
- "type" : "titlebar",
- "style" : ("attach",),
- "x" : 6,
- "y" : 6,
- "width" : BOARD_WIDTH - 10,
- "color" : "yellow",
- "children" :
- (
- {
- "name" : "TitleName",
- "type" : "text",
- "x" : 0,
- "y" : 3,
- "text" : "Statuspunkte",
- "horizontal_align" : "center",
- "text_horizontal_align" : "center",
- },
- ),
- },
- ## STR
- {
- "name" : "STR_Label",
- "type" : "window",
- "x" : 20,
- "y" : 32,
- "width" : BOARD_WIDTH - 20,
- "height" : 45,
- "children" :
- (
- {
- "name" : "STR_Text",
- "type" : "text",
- "x" : 0,
- "y" : 3,
- "text" : "Stärke (STR)",
- },
- {
- "name" : "STR_Value",
- "type" : "text",
- "x" : 0,
- "y" : 23,
- "text":"999",
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- },
- {
- "name" : "STR_Plus",
- "type" : "button",
- "x" : 197,
- "y" : 23,
- "default_image" : ROOT_PATH+"btn_plus_up.sub",
- "over_image" : ROOT_PATH+"btn_plus_over.sub",
- "down_image" : ROOT_PATH+"btn_plus_down.sub",
- },
- {
- "name":"STR_Slot",
- "type":"image",
- "x":125,
- "y":20,
- "image" : "d:/ymir work/ui/public/parameter_slot_02.sub",
- "children" :
- (
- {
- "name" : "STR_Add",
- "type" : "editline",
- "x" : 61/2,
- "y" : 3,
- "width" : 20,
- "height" : 18,
- "text" : "0",
- "only_number" : 1,
- "input_limit" : 2,
- "enable_codepage" : 0,
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- "text_horizontal_align" : "center",
- },
- ),
- },
- {
- "name" : "STR_Gauge",
- "type" : "gauge",
- "x" : 110,
- "y" : 7,
- "width" : 100,
- "color" : "purple",
- },
- ),
- },
- {
- "name" : "DEX_Label",
- "type" : "window",
- "x" : 20,
- "y" : 82,
- "width" : BOARD_WIDTH - 20,
- "height" : 45,
- "children" :
- (
- {
- "name" : "DEX_Text",
- "type" : "text",
- "x" : 0,
- "y" : 3,
- "text" : "Beweglichkeit (DEX)",
- },
- {
- "name" : "DEX_Value",
- "type" : "text",
- "x" : 0,
- "y" : 23,
- "text":"999",
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- },
- {
- "name" : "DEX_Plus",
- "type" : "button",
- "x" : 197,
- "y" : 23,
- "default_image" : ROOT_PATH+"btn_plus_up.sub",
- "over_image" : ROOT_PATH+"btn_plus_over.sub",
- "down_image" : ROOT_PATH+"btn_plus_down.sub",
- },
- {
- "name":"DEX_Slot",
- "type":"image",
- "x":125,
- "y":20,
- "image" : "d:/ymir work/ui/public/parameter_slot_02.sub",
- "children" :
- (
- {
- "name" : "DEX_Add",
- "type" : "editline",
- "x" : 61/2,
- "y" : 3,
- "width" : 20,
- "height" : 18,
- "text" : "0",
- "only_number" : 1,
- "input_limit" : 2,
- "enable_codepage" : 0,
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- "text_horizontal_align" : "center",
- },
- ),
- },
- {
- "name" : "DEX_Gauge",
- "type" : "gauge",
- "x" : 110,
- "y" : 7,
- "width" : 100,
- "color" : "blue",
- },
- ),
- },
- {
- "name" : "HTH_Label",
- "type" : "window",
- "x" : 20,
- "y" : 132,
- "width" : BOARD_WIDTH - 20,
- "height" : 45,
- "children" :
- (
- {
- "name" : "HTH_Text",
- "type" : "text",
- "x" : 0,
- "y" : 3,
- "text" : "Vitalität (VIT)",
- },
- {
- "name" : "HTH_Value",
- "type" : "text",
- "x" : 0,
- "y" : 23,
- "text":"999",
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- },
- {
- "name" : "HTH_Plus",
- "type" : "button",
- "x" : 197,
- "y" : 23,
- "default_image" : ROOT_PATH+"btn_plus_up.sub",
- "over_image" : ROOT_PATH+"btn_plus_over.sub",
- "down_image" : ROOT_PATH+"btn_plus_down.sub",
- },
- {
- "name":"HTH_Slot",
- "type":"image",
- "x":125,
- "y":20,
- "image" : "d:/ymir work/ui/public/parameter_slot_02.sub",
- "children" :
- (
- {
- "name" : "HTH_Add",
- "type" : "editline",
- "x" : 61/2,
- "y" : 3,
- "width" : 20,
- "height" : 18,
- "text" : "0",
- "only_number" : 1,
- "input_limit" : 2,
- "enable_codepage" : 0,
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- "text_horizontal_align" : "center",
- },
- ),
- },
- {
- "name" : "HTH_Gauge",
- "type" : "gauge",
- "x" : 110,
- "y" : 7,
- "width" : 100,
- "color" : "red",
- },
- ),
- },
- {
- "name" : "INT_Label",
- "type" : "window",
- "x" : 20,
- "y" : 182,
- "width" : BOARD_WIDTH - 20,
- "height" : 45,
- "children" :
- (
- {
- "name" : "INT_Text",
- "type" : "text",
- "x" : 0,
- "y" : 3,
- "text" : "Intelligenz (INT)",
- },
- {
- "name" : "INT_Value",
- "type" : "text",
- "x" : 0,
- "y" : 23,
- "text":"999",
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- },
- {
- "name" : "INT_Plus",
- "type" : "button",
- "x" : 197,
- "y" : 23,
- "default_image" : ROOT_PATH+"btn_plus_up.sub",
- "over_image" : ROOT_PATH+"btn_plus_over.sub",
- "down_image" : ROOT_PATH+"btn_plus_down.sub",
- },
- {
- "name":"INT_Slot",
- "type":"image",
- "x":125,
- "y":20,
- "image" : "d:/ymir work/ui/public/parameter_slot_02.sub",
- "children" :
- (
- {
- "name" : "INT_Add",
- "type" : "editline",
- "x" : 61/2,
- "y" : 3,
- "width" : 20,
- "height" : 18,
- "text" : "0",
- "only_number" : 1,
- "input_limit" : 2,
- "enable_codepage" : 0,
- "r" : 1.0,
- "g" : 1.0,
- "b" : 1.0,
- "a" : 1.0,
- "text_horizontal_align" : "center",
- },
- ),
- },
- {
- "name" : "INT_Gauge",
- "type" : "gauge",
- "x" : 110,
- "y" : 7,
- "width" : 100,
- "color" : "pink",
- },
- ),
- },
- ),
- },
- ),
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement