Jump to content

Metin2 - Extended Modules for ScriptWindow


Recommended Posts

  • Forum Moderator

M2 Download Center

This is the hidden content, please
( Internal )

This is the hidden content, please
( GitHub )

This is the hidden content, please

  • Metin2 Dev 28
  • Angry 1
  • Sad 1
  • Think 1
  • Confused 2
  • Good 6
  • Love 28
Link to comment
Share on other sites

  • Forum Moderator
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",
				},
			),
		},
	),
}

 

 

Link to comment
Share on other sites

  • 1 year later...

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.