Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import dbg, app, net, ui, wndMgr, chr
- URL_FILE_NAME = 'lib/color'
- class kolorDialog(ui.ScriptWindow):
- def __init__(self):
- ui.ScriptWindow.__init__(self)
- self.LoadDialog()
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def LoadDialog(self):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, "interfececolor.py")
- except:
- import exception
- exception.Abort("kolorDialog.Initialize.LoadDialog")
- try:
- GetObject = self.GetChild
- self.btnSave = GetObject("ok")
- self.btnRestart = GetObject("no")
- self.board = GetObject("board")
- self.sliderList = [GetObject("r"), GetObject("g"), GetObject("b"), GetObject("a")]
- self.textList = [GetObject("rt"), GetObject("gt"), GetObject("bt"), GetObject("at")]
- self.interfaceList = [
- self.board.Corners[0], self.board.Corners[1], self.board.Corners[2], self.board.Corners[3], self.board.Lines[0], self.board.Lines[1], self.board.Lines[2], self.board.Lines[3],
- self.board.Base, self.board.titleBar.imgLeft, self.board.titleBar.imgCenter, self.board.titleBar.imgRight]
- except:
- import exception
- exception.Abort("kolorDialog.Initialize.BindObject")
- self.board.SetCloseEvent(self.Close)
- self.btnSave.SetEvent(ui.__mem_func__(self.OnPressSaveButton))
- self.btnRestart.SetEvent(ui.__mem_func__(self.OnPressRestartButton))
- self.Refresh()
- def GetSliderPos(self):
- return self.sliderList[0], self.sliderList[1], self.sliderList[2], self.sliderList[3]
- def SetSliderPos(self, r, g, b, a):
- [value.SetSliderPos([r, g, b, a][key]) for key, value in enumerate(self.sliderList)]
- def Refresh(self):
- def split(vars):
- return str(vars * 255).split('.')[0]
- r, g, b, a = GetSliderPos()
- [wndMgr.SetDiffuseColor(object.hWnd, r, g, b, (a / 2 ) + 0.5) for object in self.interfaceList]
- [value.SetText([split(r), split(g), split(b), split(a)][key]) for key, value in enumerate(self.textList)]
- def OpenDialog(self):
- def tokens():
- return open(URL_FILE_NAME).readlines()
- self.SetSliderPos(float(tokens()[0]), float(tokens()[1]), float(tokens()[2]), (float(tokens()[3]) - 0.5) * 2)
- self.Show()
- self.Refresh()
- def OnPressSaveButton(self):
- r, g, b, a = GetSliderPos()
- ui.zmiengrafike(r, g, b, (a / 2) + 0.5)
- f = open(URL_FILE_NAME, 'wb')
- f.write("%s\n%s\n%s\n%s\n" % (r, g, b, (a / 2) + 0.5))
- f.close()
- self.Refresh()
- def OnPressRestartButton(self):
- self.SetSliderPos(1.0, 1.0, 1.0, 1.0)
- self.Refresh()
- def OnPressEscapeKey(self):
- self.Close()
- return TRUE
- def Close(self):
- self.Hide()
- return TRUE
Advertisement
Add Comment
Please, Sign In to add comment