Paste 9J2PTCI4

Submitted on 22 October 2026 at 20:45 UTC
Expires on 21 November 2026 at 20:45 UTC
67 views

game.py (text)

#-*- coding: iso-8859-1 -*-
import os
import app

if app.ENABLE_DROPINFO_REWORK:
	import uiDropInfo

import dbg
import grp
import item
import background
import chr
import chrmgr
import player
import snd
import chat
import textTail
import snd
import net
import wndMgr
import acce
import systemSetting
import quest
import guild
import skill
import messenger
import localeInfo
import constInfo
import exchange
import ime
import time
import uiScriptLocale

import ui
import dungeonentrynotice
import uiSkillTreeEffects
import specialeffectstate
import uiCommon
import uigmpanel
import uiPhaseCurtain
import uiMapNameShower
import uiAffectShower
import uiPlayerGauge
import uiCharacter
import uiTarget
import uiMount
import uiPrivateShopBuilder

import mouseModule
import consoleModule
import localeInfo
import interfaceModule
if app.ENABLE_SKILL_SELECT_FEATURE:
	import uiskillchoose
if app.ENABLE_OFFLINE_SHOP:
    import uiOfflineShop, offlineshop

import musicInfo
import debugInfo
import stringCommander
if app.ENABLE_KEYCHANGE_SYSTEM:
	import uiKeyChange
if app.ENABLE_OFFLINE_SHOP_SYSTEM:
	import uiOfflineShopBuilder
	import uiOfflineShop

if app.ENABLE_PREMIUM_PRIVATE_SHOP_OFFICIAL:
	import uiPrivateShop

import uiCube
import uisecurity
import uiRanking
import uiEnlightenment
import uiminingpass
import uiFishWiki
if app.ENABLE_ITEMSHOP:
	import uiItemShopNew

if app.ENABLE_IN_GAME_LOG_SYSTEM:
	import uiingamelog
	
import tween
import tweenCamera
import cinemachine

if app.ENABLE_MESSENGER2:
	import messenger2storage

from _weakref import proxy

SCREENSHOT_CWDSAVE = True
SCREENSHOT_DIR = None

cameraDistance = 1550.0
cameraPitch = 27.0
cameraRotation = 0.0
cameraHeight = 100.0

testAlignment = 0

class GameWindow(ui.ScriptWindow):
	def __init__(self, stream):
		if hasattr(item, "SetPrimeCapeState"):
			item.SetPrimeCapeState(0, 0, 0)
		ui.ScriptWindow.__init__(self, "GAME")
		self.SetWindowName("game")
		self.noUIMode = False
		self.noUIChatWasShown = False
		self.grassEditor = None
		if hasattr(background, "GrassEditorStatus"):
			import uigrasseditor
			self.grassEditor = uigrasseditor.GrassEditor()
		self.metinSelection = None
		if hasattr(player, "GetQueueCandidates"):
			import uiMetinQueue
			self.metinSelection = uiMetinQueue.MetinSelection()
		net.SetPhaseWindow(net.PHASE_WINDOW_GAME, self)
		player.SetGameWindow(self)
		constInfo.IS_VIP = False
		self.queuePassActive = False
		self.queuePassDuration = 0
		self.vipDuration = 0
		if hasattr(player, "SetQueueLimit"):
			player.SetQueueLimit(5)

		self.quickSlotPageIndex = 0
		self.lastPKModeSendedTime = 0
		self.pressNumber = None

		if app.ENABLE_BOT_CONTROL:
			self.botControlWnd = None
			self._activityCaptchaProtocol = False

		if app.ENABLE_SKILL_SELECT_FEATURE:
			self.skillSelect = None

		self.guildWarQuestionDialog = None
		self.interface = None
		self.targetBoard = None
		self.console = None
		self.mapNameShower = None
		self.affectShower = None
		self.playerGauge = None

		if app.ENABLE_DROPINFO_REWORK:
			self.wndDropInfo = None

		if app.ENABLE_IN_GAME_LOG_SYSTEM:
			 self.wndInGameLog = uiingamelog.IngameLogWindow()
		if app.ENABLE_KEYCHANGE_SYSTEM:
			self.wndKeyChange = None

		if app.ENABLE_AUTO_SHOUT:
			self.lastShoutTime = 0

		self.stream=stream
		self.interface = interfaceModule.Interface()
		if app.ENABLE_EVENT_MANAGER:
			constInfo.SetInterfaceInstance(self.interface)
		interfaceModule.SetInstance(self.interface)
		self.interface.MakeInterface()
		if self.metinSelection:
			self.interface.wndMiniMap.SetMetinQueueEvent(ui.__mem_func__(self.metinSelection.TogglePanel))
		self.interface.ShowDefaultWindows()
		self.gmPanel = uigmpanel.Controller()

		if app.__MAINTENANCE__:
			self.maintenance = self.stream.GetMaintenanceWindow()
		constInfo.SetInterfaceInstance(self.interface)

		self.curtain = uiPhaseCurtain.PhaseCurtain()
		#self.curtain.speed = 0.03
		self.curtain.Hide()

		self.targetBoard = uiTarget.TargetBoard()
		import uiworldbossparticipation
		self.worldbossProgress = uiworldbossparticipation.WorldbossParticipationBoard()
		import uiworldbossencounter
		self.worldbossEncounter = uiworldbossencounter.WorldbossEncounterOverlay()
		self.targetBoard.SetWhisperEvent(ui.__mem_func__(self.interface.OpenWhisperDialog))
		self.targetBoard.Hide()

		if app.ENABLE_OFFLINE_SHOP:
			offlineshop.HideShopNames()
			
		if app.ENABLE_SKILL_SELECT_FEATURE:
			self.skillSelect = uiselectskill.SkillSelectWindow()
			self.skillSelect.Hide()

		self.console = consoleModule.ConsoleWindow()
		self.console.BindGameClass(self)
		self.console.SetConsoleSize(wndMgr.GetScreenWidth(), 200)
		self.console.Hide()

		self.mapNameShower = uiMapNameShower.MapNameShower()
		self.affectShower = uiAffectShower.AffectShower()
		if app.__MAINTENANCE__:
			self.maintenance.SetAffectShower(self.affectShower)

		self.enlightWindow = None
		self.miningAttemptOverlay = None
		
		self.rankingWindow = uiRanking.RankingWindow()
		self.weeklyRankingWindow = uiRanking.WeeklyRankingWindow()
		self.fishWikiWindow = uiFishWiki.FishingWikipediaWindow()


		self.playerGauge = uiPlayerGauge.PlayerGauge(self)
		self.playerGauge.Hide()
		
		self.cinemachineWindow = cinemachine.CinemachineWindow()
		self.cinemachineWindow.Hide()

		self.tweenMgr = tween.TweenManager()
		
		self.itemDropQuestionDialog = None

		self.__SetQuickSlotMode()

		# Himmel: mit Solaria_Grafik.exe das Mythos-Himmelsystem, sonst die alte Auswahl
		import skyboxsystem
		if skyboxsystem.IsAvailable():
			skyboxsystem.Apply(True)
		elif app.ENABLE_SKYBOX_SELECT:
			self.interface.wndgameOption.RefreshSkyBoxButtons()

		self.__ServerCommand_Build()
		self.__ProcessPreservedServerCommand()
		if app.ENABLE_KEYCHANGE_SYSTEM:
			self.wndKeyChange = uiKeyChange.KeyChangeWindow(self, self.interface)
			self.ADDKEYBUFFERCONTROL = player.KEY_ADDKEYBUFFERCONTROL
			self.ADDKEYBUFFERALT = player.KEY_ADDKEYBUFFERALT
			self.ADDKEYBUFFERSHIFT = player.KEY_ADDKEYBUFFERSHIFT

	def __del__(self):
		if hasattr(player, "ClearGameWindow"):
			player.ClearGameWindow(self)
		net.ClearPhaseWindow(net.PHASE_WINDOW_GAME, self)
		ui.ScriptWindow.__del__(self)

	def Open(self):
		specialeffectstate.clear()
		self.skillTreeEffectHUD = uiSkillTreeEffects.EffectHUD()
		app.SetFrameSkip(1)
		if self.interface and self.interface.wndBonus:
			self.interface.wndBonus.EnsureProfile()

		self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())

		self.quickSlotPageIndex = 0
		self.PickingCharacterIndex = -1
		self.PickingItemIndex = -1
		self.consoleEnable = False
		self.isShowDebugInfo = False
		self.ShowNameFlag = False
		self.isCinemaMode = False;
		self.freeCameraSpeed = 1
		self.cameraFov = 30

		self.enableXMasBoom = False
		self.startTimeXMasBoom = 0.0
		self.indexXMasBoom = 0

		global cameraDistance, cameraPitch, cameraRotation, cameraHeight

		app.SetCamera(cameraDistance, cameraPitch, cameraRotation, cameraHeight)

		constInfo.SET_DEFAULT_CAMERA_MAX_DISTANCE()
		constInfo.SET_DEFAULT_CHRNAME_COLOR()
		constInfo.SET_DEFAULT_FOG_LEVEL()

		# Kamera-/Nebelstufe aus metin2.cfg (neues Optionsfenster, nur Solaria_Grafik.exe)
		if hasattr(systemSetting, "GetCameraMode"):
			constInfo.SET_CAMERA_MAX_DISTANCE_INDEX(systemSetting.GetCameraMode())
		if hasattr(systemSetting, "GetFogMode"):
			constInfo.SET_FOG_LEVEL_INDEX(systemSetting.GetFogMode())
		constInfo.SET_DEFAULT_CONVERT_EMPIRE_LANGUAGE_ENABLE()
		constInfo.SET_DEFAULT_USE_ITEM_WEAPON_TABLE_ATTACK_BONUS()
		constInfo.SET_DEFAULT_USE_SKILL_EFFECT_ENABLE()

		constInfo.SET_TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE()

		import event
		event.SetLeftTimeString(localeInfo.UI_LEFT_TIME)

		textTail.EnablePKTitle(constInfo.PVPMODE_ENABLE)

		if constInfo.PVPMODE_TEST_ENABLE:
			self.testPKMode = ui.TextLine()
			self.testPKMode.SetFontName(localeInfo.UI_DEF_FONT)
			self.testPKMode.SetPosition(0, 15)
			self.testPKMode.SetWindowHorizontalAlignCenter()
			self.testPKMode.SetHorizontalAlignCenter()
			self.testPKMode.SetFeather()
			self.testPKMode.SetOutline()
			self.testPKMode.Show()

			self.testAlignment = ui.TextLine()
			self.testAlignment.SetFontName(localeInfo.UI_DEF_FONT)
			self.testAlignment.SetPosition(0, 35)
			self.testAlignment.SetWindowHorizontalAlignCenter()
			self.testAlignment.SetHorizontalAlignCenter()
			self.testAlignment.SetFeather()
			self.testAlignment.SetOutline()
			self.testAlignment.Show()

		self.__BuildKeyDict()
		if app.ENABLE_KEYCHANGE_SYSTEM:
			pass
		self.__BuildDebugInfo()

		constInfo.IS_BONUS_CHANGER = False
		constInfo.IS_ACCE_WINDOW = False
		constInfo.IS_DRAGON_SOUL_OPEN = False

		uiPrivateShopBuilder.Clear()
		if app.ENABLE_OFFLINE_SHOP_SYSTEM:
			uiOfflineShopBuilder.Clear()

		exchange.InitTrading()

		if len(constInfo.lastSentenceStack) > 0:
			constInfo.lastSentencePos = 0

		snd.SetMusicVolume(systemSetting.GetMusicVolume()*net.GetFieldMusicVolume())
		snd.SetSoundVolume(systemSetting.GetSoundVolume())

		netFieldMusicFileName = net.GetFieldMusicFileName()
		if netFieldMusicFileName:
			snd.FadeInMusic("sound/BGM/" + netFieldMusicFileName)
		elif musicInfo.fieldMusic != "":
			snd.FadeInMusic("sound/BGM/" + musicInfo.fieldMusic)
		player.LoadBossNPC()
		self.__SetQuickSlotMode()
		self.__SelectQuickPage(self.quickSlotPageIndex)

		self.SetFocus()
		self.Show()
		app.ShowCursor()

		net.SendEnterGamePacket()
		dungeonentrynotice.Restore(self.interface, self.stream, player.GetName(), background.GetCurrentMapName(), app.GetTime())

		try:
			self.StartGame()
		except:
			import exception
			exception.Abort("GameWindow.Open")

		if app.ENABLE_AUTO_SHOUT:
			self.lastShoutTime = app.GetTime() + constInfo.SHOUT_PER_SECOND

	if app.__MAINTENANCE__:
		def SetMaintenance(self, mode, startTime, endTime, status, reason, eventId=0):
			self.stream.SetMaintenance(mode, startTime, endTime, status, reason, eventId)

	def Close(self):
		self.SetNoUIMode("off")
		dungeonentrynotice.Capture(self.interface, self.stream, player.GetName(), background.GetCurrentMapName(), app.GetTime())
		if hasattr(player, "ClearGameWindow"):
			player.ClearGameWindow(self)
		self.gmPanel.Destroy()
		if app.ENABLE_ITEMSHOP:
			import uiItemShopBundle
			uiItemShopBundle.Reset()
		if hasattr(item, "SetPrimeCapeState"):
			item.SetPrimeCapeState(0, 0, 0)
		if getattr(self, "skillTreeEffectHUD", None):
			self.skillTreeEffectHUD.Clear()
			self.skillTreeEffectHUD = None
		if self.interface and getattr(self.interface, "wndSkillTree", None):
			self.interface.wndSkillTree.Destroy()
		if self.miningAttemptOverlay is not None:
			self.miningAttemptOverlay.Hide()
			self.miningAttemptOverlay = None
		if self.grassEditor:
			self.grassEditor.Close()
			self.grassEditor = None
		if self.metinSelection:
			self.metinSelection.Destroy()
			self.metinSelection = None
		if app.__MAINTENANCE__:
			# The main stream owns the overlay across all phase changes.
			if self.maintenance:
				self.maintenance.SetAffectShower(None)
			self.maintenance = None
		self.Hide()

		global cameraDistance, cameraPitch, cameraRotation, cameraHeight
		(cameraDistance, cameraPitch, cameraRotation, cameraHeight) = app.GetCamera()

		if musicInfo.fieldMusic != "":
			snd.FadeOutMusic("sound/BGM/"+ musicInfo.fieldMusic)

		self.onPressKeyDict = None
		self.onClickKeyDict = None

		if app.ENABLE_MULTI_FARM_BLOCK:
			# Keep the normal taskbar icon when leaving the game phase.
			app.SetMultiFarmExeIcon(1)
		chat.Close()
		snd.StopAllSound()
		grp.InitScreenEffect()
		chr.Destroy()
		textTail.Clear()
		quest.Clear()
		background.Destroy()
		guild.Destroy()
		messenger.Destroy()

		if app.ENABLE_MESSENGER2:
			messenger2storage.Destroy()
			
		if app.ENABLE_SKILL_SELECT_FEATURE and self.skillSelect:
			self.skillSelect.Destroy()
			self.skillSelect = None
		skill.ClearSkillData()
		wndMgr.Unlock()
		mouseModule.mouseController.DeattachObject()

		if self.guildWarQuestionDialog:
			self.guildWarQuestionDialog.Close()

		self.guildNameBoard = None
		self.partyRequestQuestionDialog = None
		self.partyInviteQuestionDialog = None
		if app.ENABLE_DROPINFO_REWORK:
			self.wndDropInfo = None
		self.guildInviteQuestionDialog = None
		self.guildWarQuestionDialog = None
		self.messengerAddFriendQuestion = None
		self.cinemachineWindow.Destroy()
		self.cinemachineWindow = None

		self.tweenMgr.Destroy()

		if app.ENABLE_IN_GAME_LOG_SYSTEM:
			if self.wndInGameLog:
				self.wndInGameLog.Destroy()
				self.wndInGameLog = None

		if app.ENABLE_BOT_CONTROL:
			if self.botControlWnd:
				self.botControlWnd.Close()
				self.botControlWnd = None

		self.itemDropQuestionDialog = None

		self.confirmDialog = None

		self.PrintCoord = None
		self.FrameRate = None
		self.Pitch = None
		self.Splat = None
		self.TextureNum = None
		self.ObjectNum = None
		self.ViewDistance = None
		self.PrintMousePos = None

		self.ClearDictionary()

		self.playerGauge = None
		self.mapNameShower = None
		if self.affectShower:
			self.affectShower.SetBraveryCape(0, 0, 0, 0)
		self.affectShower = None

		if self.console:
			self.console.BindGameClass(0)
			self.console.Close()
			self.console=None

		if self.targetBoard:
			self.targetBoard.Destroy()
			self.targetBoard = None
		if getattr(self, "worldbossEncounter", None):
			self.worldbossEncounter.Reset()
			self.worldbossEncounter = None
		if getattr(self, "worldbossProgress", None):
			self.worldbossProgress.Hide()
			self.worldbossProgress = None

		if self.interface:
			self.interface.HideAllWindows()
			self.interface.Close()
			self.interface=None

		if self.fishWikiWindow:
			self.fishWikiWindow.Close()
			self.fishWikiWindow = None
			
		if self.rankingWindow:
			self.rankingWindow.Close()
			self.rankingWindow = None

		if self.enlightWindow != None:
			self.enlightWindow.Close()
			self.enlightWindow = None

		if self.weeklyRankingWindow:
			self.weeklyRankingWindow.Close()
			self.weeklyRankingWindow = None
			
		interfaceModule.SetInstance(None)

		player.ClearSkillDict()
		player.ResetCameraRotation()

		self.KillFocus()
		if app.ENABLE_EVENT_MANAGER:
			constInfo.SetInterfaceInstance(None)
		constInfo.SetInterfaceInstance(None)
		app.HideCursor()
		if app.ENABLE_KEYCHANGE_SYSTEM:
			if self.wndKeyChange:
				self.wndKeyChange.KeyChangeWindowClose(True)
				self.wndKeyChange = None
				
		if app.ENABLE_VOTE4BUFF:
			constInfo.VOTE4BUFF_DATA["LOADED"] = False

		print "---------------------------------------------------------------------------- CLOSE GAME WINDOW"

	if app.CRAFTING_SYSTEM:
		def BINARY_ADD_CRAFTING(self):
			if self.interface and self.interface.wndCrafting:
				if self.interface.wndCrafting.IsShow():
					self.interface.wndCrafting.Open()

	def ToggleCameraMode(self):
		self.__SetFreeCamera()

	def __SetFreeCamera(self):
		self.isCinemaMode = not self.isCinemaMode
		app.FreeCamera()

		if self.isCinemaMode:
			chat.AppendChat(chat.CHAT_TYPE_INFO, "Cinematic mode ON!")
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, "Cinematic mode OFF!")

	def __AddCameraFov(self):
		if not self.isCinemaMode:
			return

		self.cameraFov += 2
		app.SetFov(self.cameraFov)

	def __SubtractCameraFov(self):
		if not self.isCinemaMode:
			return

		self.cameraFov -= 2
		app.SetFov(self.cameraFov)

	def __AddFreeCameraSpeed(self, speed=0.05):
		if not self.isCinemaMode:
			return

		self.freeCameraSpeed += speed
		app.FreeCameraSpeed(self.freeCameraSpeed)

	def __SubtractFreeCameraSpeed(self, speed=0.05):
		if not self.isCinemaMode:
			return

		self.freeCameraSpeed -= speed
		app.FreeCameraSpeed(self.freeCameraSpeed)

	def CreateBezierPath(self, valueKey, num_points):
		import mathUtils

		waypoints = []
		n = len(constInfo.CAMERA_WAYPOINTS)
		for i in range(n):
			waypoints.append(constInfo.CAMERA_WAYPOINTS[i][valueKey])

		for i in range(num_points):
			t = i / float(num_points - 1)
			point = 0
			if valueKey == "rotation":
				point = mathUtils.bezier_rotation(t, *waypoints)
			else:
				point = mathUtils.bezier(t, *waypoints)
			if not constInfo.CAMERA_BEZIER_POINTS.has_key(valueKey):
				constInfo.CAMERA_BEZIER_POINTS[valueKey] = {}
			constInfo.CAMERA_BEZIER_POINTS[valueKey][i] = point

	def TestFreeCamera(self, num):
		(distance, pitch, rotation, height) = app.GetCamera()
		(x, y, z) = app.GetCameraPosition()

		if num == 1: # add waypoint
			(distance, pitch, rotation, height) = app.GetCamera()
			(x, y, z) = app.GetCameraPosition()

			waypointIndex = len(constInfo.CAMERA_WAYPOINTS)
			constInfo.CAMERA_WAYPOINTS[waypointIndex] = {
				"x" : x,
				"y" : y,
				"z" : z,
				"distance" : distance,
				"pitch" : pitch,
				"rotation" : rotation,
				"fov" : self.cameraFov,
			}

			chat.AppendChat(chat.CHAT_TYPE_INFO, "Added camera waypoint (%d) x: %d, y: %d, z: %d, distance: %d, pitch: %d, rotation: %d" %
							(waypointIndex, x, y, z, distance, pitch, rotation))

		elif num == 2:  # reset waypoints
			constInfo.CAMERA_WAYPOINTS = {}
			chat.AppendChat(chat.CHAT_TYPE_INFO, "Reset camera waypoints.")

		elif num == 3: # play waypoints bezier
			if len(constInfo.CAMERA_WAYPOINTS) < 1:
				return

			cameraTween = None
			if self.cinemachineWindow.cameraInterpolationMode == self.cinemachineWindow.MODE_BEZIER:
				num_points = 20

				isBezierRotation = False
				constInfo.CAMERA_BEZIER_POINTS = {}
				self.CreateBezierPath("x", num_points)
				self.CreateBezierPath("y", num_points)
				self.CreateBezierPath("z", num_points)
				self.CreateBezierPath("distance", num_points)
				self.CreateBezierPath("pitch", num_points)
				if self.cinemachineWindow.rotationInterpolationMode == self.cinemachineWindow.ROTATION_MODE_BEZIER:
					self.CreateBezierPath("rotation", num_points)
					isBezierRotation = True
				self.CreateBezierPath("fov", num_points)

				cameraTween = tweenCamera.CameraBezierTween(self.cinemachineWindow.TWEEN_DURATION, num_points, isBezierRotation)
			else:
				cameraTween = tweenCamera.CameraLerpTween(self.cinemachineWindow.TWEEN_DURATION)

			self.tweenMgr.CreateTween(cameraTween)
			cameraTween.StartTween()

		elif num == 4:
			self.cinemachineWindow.Toggle()

	def __BuildKeyDict(self):
		onPressKeyDict = {}


		onPressKeyDict[app.DIK_1]	= lambda : self.__PressNumKey(1)
		if app.__AUTO_SKILL_READER__:
			onPressKeyDict[app.DIK_K] = lambda : self.interface.OpenAutoSkillReader()
		onPressKeyDict[app.DIK_2]	= lambda : self.__PressNumKey(2)
		onPressKeyDict[app.DIK_3]	= lambda : self.__PressNumKey(3)
		onPressKeyDict[app.DIK_4]	= lambda : self.__PressNumKey(4)
		onPressKeyDict[app.DIK_5]	= lambda : self.__PressNumKey(5)
		onPressKeyDict[app.DIK_6]	= lambda : self.__PressNumKey(6)
		onPressKeyDict[app.DIK_7]	= lambda : self.__PressNumKey(7)
		onPressKeyDict[app.DIK_8]	= lambda : self.__PressNumKey(8)
		onPressKeyDict[app.DIK_9]	= lambda : self.__PressNumKey(9)
		onPressKeyDict[app.DIK_F1]	= lambda : self.__PressQuickSlot(4)
		onPressKeyDict[app.DIK_F2]	= lambda : self.__PressQuickSlot(5)
		onPressKeyDict[app.DIK_F3]	= lambda : self.__PressQuickSlot(6)
		onPressKeyDict[app.DIK_F4]	= lambda : self.__PressQuickSlot(7)
		# F5 oeffnet den Switchbot. Vorher lag hier ToggleCameraMode - das
		# bleibt auf END erreichbar, geht also nicht verloren.
		#
		# Diese Zeile greift nur, wenn ENABLE_KEYCHANGE_SYSTEM aus ist: sonst
		# wertet OnKeyDown das Dict nicht aus. Fuer den Normalfall steht die
		# Bindung dort im Tastenbelegungs-Zweig.
		if app.ENABLE_SWITCHBOT:
			onPressKeyDict[app.DIK_F5] = lambda: self.interface.ToggleSwitchbotWindow()

		onPressKeyDict[app.DIK_END] = lambda: self.ToggleCameraMode()           # Insert (key-change system)
		#onPressKeyDict[app.DIK_PGUP]   = lambda: self.__AddFreeCameraSpeed()       # PageUp
		#onPressKeyDict[app.DIK_PGDN]   = lambda: self.__SubtractFreeCameraSpeed()  # PageDown
		onPressKeyDict[app.DIK_PGUP]   = lambda: self.__AddCameraFov()             # Home
		onPressKeyDict[app.DIK_PGDN]    = lambda: self.__SubtractCameraFov()        # End

		onPressKeyDict[app.DIK_RETURN]	= lambda : self.ChangeBonus()

		onPressKeyDict[app.DIK_F11]	= lambda : self.interface.ToggleCollectWindow()

		onPressKeyDict[app.DIK_F12] = lambda : self.interface.ToggleCollectionWindow()

		onPressKeyDict[app.DIK_P]	= lambda : self.interface.BuffNPCOpenWindow()
		if app.WJ_SPLIT_INVENTORY_SYSTEM:
			onPressKeyDict[app.DIK_U]		= lambda : self.__PressExtendedInventory()
			

		onPressKeyDict[app.DIK_TAB]			= lambda : 		self.ToggleMapWindow()

		onPressKeyDict[app.DIK_LALT]		= lambda : self.ShowName()
		onPressKeyDict[app.DIK_LCONTROL]	= lambda : self.ShowMouseImage()
		onPressKeyDict[app.DIK_SPACE]		= lambda : self.StartAttack()

		onPressKeyDict[app.DIK_UP]			= lambda : self.MoveUp()
		onPressKeyDict[app.DIK_DOWN]		= lambda : self.MoveDown()
		onPressKeyDict[app.DIK_LEFT]		= lambda : self.MoveLeft()
		onPressKeyDict[app.DIK_RIGHT]		= lambda : self.MoveRight()
		onPressKeyDict[app.DIK_W]			= lambda : self.MoveUp()
		onPressKeyDict[app.DIK_S]			= lambda : self.MoveDown()
		onPressKeyDict[app.DIK_A]			= lambda : self.MoveLeft()
		onPressKeyDict[app.DIK_D]			= lambda : self.MoveRight()

		onPressKeyDict[app.DIK_E]			= lambda: app.RotateCamera(app.CAMERA_TO_POSITIVE)
		onPressKeyDict[app.DIK_R]			= lambda: app.ZoomCamera(app.CAMERA_TO_NEGATIVE)
		onPressKeyDict[app.DIK_T]			= lambda: app.PitchCamera(app.CAMERA_TO_NEGATIVE)
		onPressKeyDict[app.DIK_G]			= self.__PressGKey
		onPressKeyDict[app.DIK_Q]			= self.__PressQKey

		onPressKeyDict[app.DIK_NUMPAD9]		= lambda: app.MovieResetCamera()
		onPressKeyDict[app.DIK_NUMPAD4]		= lambda: app.MovieRotateCamera(app.CAMERA_TO_NEGATIVE)
		onPressKeyDict[app.DIK_NUMPAD6]		= lambda: app.MovieRotateCamera(app.CAMERA_TO_POSITIVE)
		onPressKeyDict[app.DIK_PGUP]		= lambda: app.MovieZoomCamera(app.CAMERA_TO_NEGATIVE)
		onPressKeyDict[app.DIK_PGDN]		= lambda: app.MovieZoomCamera(app.CAMERA_TO_POSITIVE)
		onPressKeyDict[app.DIK_NUMPAD8]		= lambda: app.MoviePitchCamera(app.CAMERA_TO_NEGATIVE)
		onPressKeyDict[app.DIK_NUMPAD2]		= lambda: app.MoviePitchCamera(app.CAMERA_TO_POSITIVE)
		onPressKeyDict[app.DIK_GRAVE]		= lambda : self.PickUpItem()
		onPressKeyDict[app.DIK_Z]			= lambda : self.PickUpItem()
		onPressKeyDict[app.DIK_C]			= lambda state = "STATUS": self.interface.ToggleCharacterWindow(state)
		onPressKeyDict[app.DIK_V]			= lambda state = "SKILL": self.interface.ToggleCharacterWindow(state)
		onPressKeyDict[app.DIK_N]			= lambda state = "QUEST": self.interface.ToggleCharacterWindow(state)
		onPressKeyDict[app.DIK_I]			= lambda : self.interface.ToggleInventoryWindow()
		onPressKeyDict[app.DIK_O]			= lambda : self.interface.ToggleDragonSoulWindow()
		#if app.ENABLE_PREMIUM_PRIVATE_SHOP_OFFICIAL:
		#	onPressKeyDict[app.DIK_U]			= lambda : self.interface.TogglePrivateShopPanelWindowCheck()
		onPressKeyDict[app.DIK_M]			= lambda : self.interface.PressMKey()
		onPressKeyDict[app.DIK_ADD]			= lambda : self.interface.MiniMapScaleUp()
		onPressKeyDict[app.DIK_SUBTRACT]	= lambda : self.interface.MiniMapScaleDown()
		onPressKeyDict[app.DIK_L]			= lambda : self.interface.ToggleChatLogWindow()
		onPressKeyDict[app.DIK_COMMA]		= lambda : self.ShowConsole()
		onPressKeyDict[app.DIK_LSHIFT]		= lambda : self.__SetQuickPageMode()
		onPressKeyDict[app.DIK_J]			= lambda : self.__PressJKey()
		onPressKeyDict[app.DIK_H]			= lambda : self.__PressHKey()
		onPressKeyDict[app.DIK_B]			= lambda : self.__PressBKey()
		onPressKeyDict[app.DIK_F]			= lambda : self.__PressFKey()
		if app.CRAFTING_SYSTEM:
			onPressKeyDict[app.DIK_F7]			= lambda : self.interface.ToggleCrafting()


		self.onPressKeyDict = onPressKeyDict

		onClickKeyDict = {}
		onClickKeyDict[app.DIK_UP] = lambda : self.StopUp()
		onClickKeyDict[app.DIK_DOWN] = lambda : self.StopDown()
		onClickKeyDict[app.DIK_LEFT] = lambda : self.StopLeft()
		onClickKeyDict[app.DIK_RIGHT] = lambda : self.StopRight()
		onClickKeyDict[app.DIK_SPACE] = lambda : self.EndAttack()

		onClickKeyDict[app.DIK_W] = lambda : self.StopUp()
		onClickKeyDict[app.DIK_S] = lambda : self.StopDown()
		onClickKeyDict[app.DIK_A] = lambda : self.StopLeft()
		onClickKeyDict[app.DIK_D] = lambda : self.StopRight()
		onClickKeyDict[app.DIK_Q] = lambda: app.RotateCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_E] = lambda: app.RotateCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_R] = lambda: app.ZoomCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_F] = lambda: app.ZoomCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_T] = lambda: app.PitchCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_G] = lambda: self.__ReleaseGKey()
		onClickKeyDict[app.DIK_NUMPAD4] = lambda: app.MovieRotateCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_NUMPAD6] = lambda: app.MovieRotateCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_PGUP] = lambda: app.MovieZoomCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_PGDN] = lambda: app.MovieZoomCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_NUMPAD8] = lambda: app.MoviePitchCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_NUMPAD2] = lambda: app.MoviePitchCamera(app.CAMERA_STOP)
		onClickKeyDict[app.DIK_LALT] = lambda: self.HideName()
		onClickKeyDict[app.DIK_LCONTROL] = lambda: self.HideMouseImage()
		onClickKeyDict[app.DIK_LSHIFT] = lambda: self.__SetQuickSlotMode()


		self.onClickKeyDict=onClickKeyDict

	def ChangeBonus(self):
		if constInfo.IS_BONUS_CHANGER:
			self.interface.wndChangerWindow.ChangeBonus()
		elif constInfo.IS_ACCE_WINDOW:
			acce.SendRefineRequest()
		elif constInfo.IS_DRAGON_SOUL_OPEN:
			self.interface.wndDragonSoulRefine.PressDoRefineButton()


	def __PressNumKey(self,num):
		if self.isCinemaMode:
			self.TestFreeCamera(num)
			return
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):

			if num >= 1 and num <= 9:
				if(chrmgr.IsPossibleEmoticon(-1)):
					chrmgr.SetEmoticon(-1,int(num)-1)
					net.SendEmoticon(int(num)-1)
		else:
			if num >= 1 and num <= 4:
				self.pressNumber(num-1)

	def __ClickBKey(self):
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
			return
		else:
			if constInfo.PVPMODE_ACCELKEY_ENABLE:
				self.ChangePKMode()
					
	def	__PressJKey(self):
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
			if player.IsMountingHorse():
				net.SendChatPacket("/unmount")
			else:
				if not uiPrivateShopBuilder.IsBuildingPrivateShop():
					for i in xrange(player.INVENTORY_PAGE_SIZE*player.INVENTORY_PAGE_COUNT):
						if player.GetItemIndex(i) in (71114, 71116, 71118, 71120):
							net.SendItemUsePacket(i)
							break
	def	__PressHKey(self):
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
			net.SendChatPacket("/user_horse_ride")
		else:
			# if app.ENABLE_WIKI:
				# self.interface.OpenWikiWindow()
			if app.ENABLE_WIKIPEDIA:
				self.interface.ToggleWikipedia()
			else:
				self.interface.OpenHelpWindow()
				
	def	__PressBKey(self):
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
			net.SendChatPacket("/user_horse_back")
		else:
			state = "EMOTICON"
			self.interface.ToggleCharacterWindow(state)

	def	__PressFKey(self):
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
			net.SendChatPacket("/user_horse_feed")
		else:
			app.ZoomCamera(app.CAMERA_TO_POSITIVE)

	def __PressGKey(self):
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
			net.SendChatPacket("/user_horse_ride")
		else:
			if self.ShowNameFlag:
				self.interface.ToggleGuildWindow()
			else:
				app.PitchCamera(app.CAMERA_TO_POSITIVE)

	def	__ReleaseGKey(self):
		app.PitchCamera(app.CAMERA_STOP)

	def __PressQKey(self):
		if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
			if 0==interfaceModule.IsQBHide:
				interfaceModule.IsQBHide = 1
				self.interface.HideAllQuestButton()
			else:
				interfaceModule.IsQBHide = 0
				self.interface.ShowAllQuestButton()
		else:
			app.RotateCamera(app.CAMERA_TO_NEGATIVE)

	def __SetQuickSlotMode(self):
		self.pressNumber=ui.__mem_func__(self.__PressQuickSlot)

	def __SetQuickPageMode(self):
		self.pressNumber=ui.__mem_func__(self.__SelectQuickPage)

	def __PressQuickSlot(self, localSlotIndex):
		if localeInfo.IsARABIC():
			if 0 <= localSlotIndex and localSlotIndex < 4:
				player.RequestUseLocalQuickSlot(3-localSlotIndex)
			else:
				player.RequestUseLocalQuickSlot(11-localSlotIndex)
		else:
			player.RequestUseLocalQuickSlot(localSlotIndex)

	if app.ENABLE_KEYCHANGE_SYSTEM:
		def OpenKeyChangeWindow(self):
			self.wndKeyChange.Open()

		def OpenWindow(self, type, state):
			if type == player.KEY_OPEN_STATE:
				self.interface.ToggleCharacterWindow(state)
			elif type == player.KEY_OPEN_INVENTORY:
				self.interface.ToggleInventoryWindow()
			elif type == player.KEY_OPEN_DDS:
				self.interface.ToggleDragonSoulWindow()
			elif type == player.KEY_OPEN_MINIMAP:
				self.interface.ToggleMiniMap()
			elif type == player.KEY_OPEN_LOGCHAT:
				self.interface.ToggleChatLogWindow()
			elif type == player.KEY_OPEN_GUILD:
				self.interface.ToggleGuildWindow()
			elif type == player.KEY_OPEN_MESSENGER:
				self.interface.ToggleMessenger()
			elif type == player.KEY_OPEN_HELP:
				#if app.ENABLE_WIKI:
				if app.ENABLE_WIKIPEDIA:
					self.interface.ToggleWikipedia()
				else:
					self.interface.OpenHelpWindow()
					
			elif type == player.KEY_TP_MAP:
				self.interface.OpenDungeonInfo()

			elif type == player.KEY_OPEN_EXTENDED_INV:
				self.interface.ToggleExtendedInventoryWindow()
			elif type == player.KEY_OPEN_PET:
				self.interface.BuffNPCOpenWindow()
			elif type == player.KEY_OPEN_DOPY:
				self.interface.wndBlend.btnUse()
			elif type == player.KEY_OPEN_MARBLE:
				self.interface.wndCompanionWindow.Open()
			elif type == player.KEY_OPEN_SAVE_LOCATION:
				self.interface.OpenTitleAchievement()
			elif type == player.KEY_OPEN_RESP:
				self.interface.OpenEventCalendar()
				#if app.ENABLE_RESP_SYSTEM:
				#	self.interface.OpenRespWindow()
			elif type == player.KEY_OPEN_BUFF:
				self.OpenShopSearch()
			elif type == player.KEY_OPEN_MISSION:
				self.interface.ToggleCollectWindow()
			elif type == player.KEY_OPEN_COLLECTION:
				self.interface.ToggleCollectionWindow()
			elif type == player.KEY_RETURN:
				self.ChangeBonus()
			elif type == player.KEY_OPEN_DUNGEONS:
				self.interface.OpenDungeonInfo()

			elif type == player.KEY_CHANGECHANNEL1:
				net.MoveChannelGame(1)
			elif type == player.KEY_CHANGECHANNEL2:
				net.MoveChannelGame(2)
			elif type == player.KEY_CHANGECHANNEL3:
				net.MoveChannelGame(3)
			elif type == player.KEY_CHANGECHANNEL4:
				net.MoveChannelGame(4)
			elif type == player.KEY_CHANGECHANNEL5:
				net.MoveChannelGame(5)
			elif type == player.KEY_CHANGECHANNEL6:
				net.MoveChannelGame(6)
			elif type == player.KEY_OPEN_CHANNEL_DIALOG:
				if app.BL_MOVE_CHANNEL:
					self.interface.OpenMoveChannelDialog()
			elif type == player.KEY_CHANNEL_UP:
				if app.BL_MOVE_CHANNEL:
					self.interface.ChannelUp()
			elif type == player.KEY_CHANNEL_DOWN:
				if app.BL_MOVE_CHANNEL:
					self.interface.ChannelDown()

		def ScrollOnOff(self):
			if 0 == interfaceModule.IsQBHide:
				interfaceModule.IsQBHide = 1
				self.interface.HideAllQuestButton()
			else:
				interfaceModule.IsQBHide = 0
				self.interface.ShowAllQuestButton()

	def __SelectQuickPage(self, pageIndex):
		self.quickSlotPageIndex = pageIndex
		player.SetQuickPage(pageIndex)

	def ToggleDebugInfo(self):
		self.isShowDebugInfo = not self.isShowDebugInfo

		if self.isShowDebugInfo:
			self.PrintCoord.Show()
			self.FrameRate.Show()
			self.Pitch.Show()
			self.Splat.Show()
			self.TextureNum.Show()
			self.ObjectNum.Show()
			self.ViewDistance.Show()
			self.PrintMousePos.Show()
		else:
			self.PrintCoord.Hide()
			self.FrameRate.Hide()
			self.Pitch.Hide()
			self.Splat.Hide()
			self.TextureNum.Hide()
			self.ObjectNum.Hide()
			self.ViewDistance.Hide()
			self.PrintMousePos.Hide()

	def __BuildDebugInfo(self):
		self.PrintCoord = ui.TextLine()
		self.PrintCoord.SetFontName(localeInfo.UI_DEF_FONT)
		self.PrintCoord.SetPosition(wndMgr.GetScreenWidth() - 270, 0)

		self.FrameRate = ui.TextLine()
		self.FrameRate.SetFontName(localeInfo.UI_DEF_FONT)
		self.FrameRate.SetPosition(wndMgr.GetScreenWidth() - 270, 20)

		self.Pitch = ui.TextLine()
		self.Pitch.SetFontName(localeInfo.UI_DEF_FONT)
		self.Pitch.SetPosition(wndMgr.GetScreenWidth() - 270, 40)

		self.Splat = ui.TextLine()
		self.Splat.SetFontName(localeInfo.UI_DEF_FONT)
		self.Splat.SetPosition(wndMgr.GetScreenWidth() - 270, 60)

		self.PrintMousePos = ui.TextLine()
		self.PrintMousePos.SetFontName(localeInfo.UI_DEF_FONT)
		self.PrintMousePos.SetPosition(wndMgr.GetScreenWidth() - 270, 80)

		self.TextureNum = ui.TextLine()
		self.TextureNum.SetFontName(localeInfo.UI_DEF_FONT)
		self.TextureNum.SetPosition(wndMgr.GetScreenWidth() - 270, 100)

		self.ObjectNum = ui.TextLine()
		self.ObjectNum.SetFontName(localeInfo.UI_DE…

Raw · Download

Pastee