VegaS™

python Metin2 - Extended modules for ScriptWindow

4 posts in this topic

21 minutes ago, MrQuin said:

Can you show us an example?

  • root/main.py
Spoiler

import ui, exception, dbg

class MainWindow(ui.ScriptWindow):
	def __init__(self):
		ui.ScriptWindow.__init__(self)
		self.__LoadWindow()

	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def Destroy(self):
		self.ClearDictionary()
	
	def __LoadWindow(self):
		try:
			ui.PythonScriptLoader().LoadScriptFile(self, "uiScript/main_window.py")
		except:
			exception.Abort("MainWindow.__LoadWindow.LoadWindow")
			
		try:
			self.childrenDict = self.GetChildDictionary("HideButton", "ShowButton", "UpdateButton")
		except:
			import exception
			exception.Abort('MainWindow.__LoadWindow.BindObject')
		
		for tabKey, tabButton in enumerate(self.childrenDict.values()):
			tabButton.SAFE_SetEvent(self.__OnToggleDown, tabKey)

	def __OnToggleDown(self, index):
		dbg.LogBox('__OnToggleDown {:d}'.format(index))
		
		if index == 0: # HideButton
			self.SAFE_SetDictionaryEvent(self.childrenDict, ('Hide'))
		elif index == 1: # ShowButton
			self.SAFE_SetDictionaryEvent(self.childrenDict, ('Show'))
		elif index == 2: # UpdateButton
			self.SAFE_SetDictionaryEvent(self.childrenDict, ('UpdateRect', 'SetTop', 'SetCenterPosition', 'Lock'))

 

  • uiscript/main_window.py
Spoiler

import uiScriptLocale

UI_WIDTH	= 115
UI_HEIGHT	= 130

window = {
	"name" : "MainWindow",
	"style" : ("movable", "float",),
	"x" : SCREEN_WIDTH / 2 - UI_WIDTH / 2,
	"y" : SCREEN_HEIGHT / 2 - UI_HEIGHT / 2,
	"width" : UI_WIDTH,
	"height" : UI_HEIGHT,
	"children" :
	(
		{
			"name" : "Board",
			"type" : "board_with_titlebar",
			"x" : 0,
			"y" : 0,
			"width" : UI_WIDTH,
			"height" : UI_HEIGHT,
			"title" : "Window",
			"children" :
			(
			    {
					"name" : "HideButton",
					"type" : "button",
					"x" : 15,
					"y" : 40,
					"text" : "HideButton",
					"default_image" : "d:/ymir work/ui/public/large_button_01.sub",
					"over_image" : "d:/ymir work/ui/public/large_button_02.sub",
					"down_image" : "d:/ymir work/ui/public/large_button_03.sub",
				},
				{
					"name" : "ShowButton",
					"type" : "button",
					"x" : 15,
					"y" : 40 + (30 * 1),
					"text" : "ShowButton",
					"default_image" : "d:/ymir work/ui/public/large_button_01.sub",
					"over_image" : "d:/ymir work/ui/public/large_button_02.sub",
					"down_image" : "d:/ymir work/ui/public/large_button_03.sub",
				},
				{
					"name" : "UpdateButton",
					"type" : "button",
					"x" : 15,
					"y" : 40 + (30 * 2),
					"text" : "UpdateButton",
					"default_image" : "d:/ymir work/ui/public/large_button_01.sub",
					"over_image" : "d:/ymir work/ui/public/large_button_02.sub",
					"down_image" : "d:/ymir work/ui/public/large_button_03.sub",
				},
			),
		},
	),
}

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.