mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
merge total remake
This commit is contained in:
55
modules/mainmenu/entergame.lua
Normal file
55
modules/mainmenu/entergame.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
function EnterGame_connectToLoginServer()
|
||||
-- create login protocol
|
||||
local protocolLogin = ProtocolLogin.create()
|
||||
|
||||
-- used to recreate enter game window
|
||||
local recreateEnterGame = function()
|
||||
loadUI("/mainmenu/ui/entergamewindow.otui")
|
||||
end
|
||||
|
||||
-- display loading message box
|
||||
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
||||
|
||||
-- cancel loading callback
|
||||
loadBox.onCancel = function(msgbox)
|
||||
-- cancel protocol and reacreate enter game window
|
||||
protocolLogin:cancel()
|
||||
recreateEnterGame()
|
||||
end
|
||||
|
||||
-- error callback
|
||||
protocolLogin.onError = function(protocol, error)
|
||||
-- destroy loading message box
|
||||
loadBox:destroy()
|
||||
|
||||
-- display error message
|
||||
local errorBox = displayErrorBox("Login Error", error)
|
||||
|
||||
-- cancel protocol and reacreate enter game window
|
||||
protocol:cancel()
|
||||
errorBox.onOk = recreateEnterGame
|
||||
end
|
||||
|
||||
-- motd callback
|
||||
protocolLogin.onMotd = function(protocol, motd)
|
||||
-- destroy loading message box
|
||||
loadBox:destroy()
|
||||
|
||||
-- display motd
|
||||
local motdNumber = string.sub(motd, 0, string.find(motd, "\n"))
|
||||
local motdText = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
|
||||
local motdBox = displayInfoBox("Message of the day", motdText)
|
||||
|
||||
-- hide main menu
|
||||
mainMenu.visible = false
|
||||
end
|
||||
|
||||
-- get account and password then login
|
||||
local enterGameWindow = rootWidget:getChild("enterGameWindow")
|
||||
local account = enterGameWindow:getChild("accountNameLineEdit").text
|
||||
local password = enterGameWindow:getChild("accountPasswordLineEdit").text
|
||||
protocolLogin:login(account, password)
|
||||
|
||||
-- destroy enter game window
|
||||
enterGameWindow:destroy()
|
||||
end
|
26
modules/mainmenu/mainmenu.otmod
Normal file
26
modules/mainmenu/mainmenu.otmod
Normal file
@@ -0,0 +1,26 @@
|
||||
Module
|
||||
name: mainmenu
|
||||
description: Create the game mainmenu, where everything starts
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
version: 0.2
|
||||
autoLoad: true
|
||||
dependencies:
|
||||
- core
|
||||
|
||||
onLoad: |
|
||||
require('entergame')
|
||||
|
||||
if not initialized then
|
||||
mainMenu = loadUI("/mainmenu/ui/mainmenu.otui")
|
||||
getRootWidget():addChild(mainMenu)
|
||||
initialized = true
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
onUnload: |
|
||||
mainMenu:destroy()
|
||||
mainMenu = nil
|
||||
initialized = false
|
||||
|
BIN
modules/mainmenu/ui/background.png
Normal file
BIN
modules/mainmenu/ui/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
53
modules/mainmenu/ui/entergamewindow.otui
Normal file
53
modules/mainmenu/ui/entergamewindow.otui
Normal file
@@ -0,0 +1,53 @@
|
||||
MainWindow
|
||||
id: enterGameWindow
|
||||
title: Enter Game
|
||||
size: 236 160
|
||||
|
||||
LargerLabel
|
||||
text: Account name
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 18
|
||||
margin.top: 28
|
||||
|
||||
LineEdit
|
||||
id: accountNameLineEdit
|
||||
text: otclient0
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin.left: 18
|
||||
margin.right: 18
|
||||
|
||||
LargerLabel
|
||||
text: Password
|
||||
anchors.left: prev.left
|
||||
anchors.top: prev.bottom
|
||||
margin.top: 8
|
||||
|
||||
LineEdit
|
||||
id: accountPasswordLineEdit
|
||||
text: 123456
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin.left: 18
|
||||
margin.right: 18
|
||||
|
||||
Button
|
||||
text: Ok
|
||||
width: 64
|
||||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 16
|
||||
margin.right: 16
|
||||
onClick: EnterGame_connectToLoginServer()
|
||||
|
||||
Button
|
||||
text: Cancel
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 16
|
||||
margin.right: 16
|
||||
onClick: function(self) self.parent:destroy() end
|
60
modules/mainmenu/ui/infowindow.otui
Normal file
60
modules/mainmenu/ui/infowindow.otui
Normal file
@@ -0,0 +1,60 @@
|
||||
MainWindow
|
||||
id: infoWindow
|
||||
title: Info
|
||||
size: 244 221
|
||||
|
||||
FlatPanel
|
||||
size: 208 129
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.top: 32
|
||||
margin.left: 18
|
||||
|
||||
Label
|
||||
align: center
|
||||
text: |-
|
||||
OTClient
|
||||
Version 0.2.0
|
||||
Created by edubart
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
margin.top: 20
|
||||
|
||||
HorizontalSeparator
|
||||
size: 190 2
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.top: 83
|
||||
margin.left: 9
|
||||
|
||||
Label
|
||||
text: Official Website
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 14
|
||||
margin.left: 9
|
||||
|
||||
Button
|
||||
text: Github Page
|
||||
size: 88 24
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 9
|
||||
margin.right: 9
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 40
|
||||
margin.left: 13
|
||||
margin.right: 13
|
||||
|
||||
Button
|
||||
text: Ok
|
||||
size: 46 24
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.top: 191
|
||||
margin.left: 188
|
||||
onClick: function(self) self.parent:destroy() end
|
47
modules/mainmenu/ui/mainmenu.otml
Normal file
47
modules/mainmenu/ui/mainmenu.otml
Normal file
@@ -0,0 +1,47 @@
|
||||
Panel
|
||||
skin: mainMenuBackground
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
Panel
|
||||
id: mainMenu
|
||||
skin: roundedGridPanel
|
||||
size: 144 162
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.left: 60
|
||||
margin.bottom: 70
|
||||
|
||||
Button
|
||||
id: enterGameButton
|
||||
text: Enter Game
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 18
|
||||
onClick: rootWidget:addChild(loadUI("entergamewindow"))
|
||||
|
||||
Button
|
||||
id: optionsButton
|
||||
text: Options
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 10
|
||||
onClick: rootWidget:addChild(loadUI("optionswindow"))
|
||||
|
||||
Button
|
||||
id: infoButton
|
||||
text: Info
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 10
|
||||
onClick: rootWidget:addChild(loadUI("infowindow"))
|
||||
|
||||
Button
|
||||
id: exitGameButton
|
||||
text: Exit
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 10
|
||||
onClick: exit()
|
38
modules/mainmenu/ui/mainmenu.otui
Normal file
38
modules/mainmenu/ui/mainmenu.otui
Normal file
@@ -0,0 +1,38 @@
|
||||
MenuButton < Button
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 10
|
||||
|
||||
Panel
|
||||
id: mainMenuBackground
|
||||
image:
|
||||
source: /mainmenu/ui/background.png
|
||||
smooth: true
|
||||
anchors.fill: parent
|
||||
|
||||
RoundedGridPanel
|
||||
id: mainMenu
|
||||
size: 144 162
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.left: 60
|
||||
margin.bottom: 70
|
||||
|
||||
MenuButton
|
||||
text: Enter Game
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 18
|
||||
onClick: rootWidget:addChild(loadUI("/mainmenu/ui/entergamewindow.otui"))
|
||||
|
||||
MenuButton
|
||||
text: Options
|
||||
onClick: rootWidget:addChild(loadUI("/mainmenu/ui/optionswindow.otui"))
|
||||
|
||||
MenuButton
|
||||
text: Info
|
||||
onClick: rootWidget:addChild(loadUI("/mainmenu/ui/infowindow.otui"))
|
||||
|
||||
MenuButton
|
||||
text: Exit
|
||||
onClick: exit()
|
112
modules/mainmenu/ui/optionswindow.otui
Normal file
112
modules/mainmenu/ui/optionswindow.otui
Normal file
@@ -0,0 +1,112 @@
|
||||
MainWindow
|
||||
id: optionsWindow
|
||||
title: Options
|
||||
size: 286 262
|
||||
|
||||
// general
|
||||
Button
|
||||
text: General
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 18
|
||||
margin.top: 32
|
||||
onClick: displayErrorBox("Error", "Not implemented yet")
|
||||
|
||||
Label
|
||||
text: |-
|
||||
Change general
|
||||
game options
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
// graphics
|
||||
Button
|
||||
text: Graphics
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 18
|
||||
margin.top: 65
|
||||
|
||||
Label
|
||||
text: |-
|
||||
Change graphics and
|
||||
performance settings
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
// console
|
||||
Button
|
||||
text: Console
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 18
|
||||
margin.top: 98
|
||||
|
||||
Label
|
||||
text: Customise the console
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
// hotkeys
|
||||
Button
|
||||
text: Hotkeys
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 18
|
||||
margin.top: 131
|
||||
|
||||
Label
|
||||
text: Edit your hotkey texts
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 97
|
||||
margin.left: 18
|
||||
margin.right: 18
|
||||
|
||||
// motd
|
||||
Button
|
||||
text: Motd
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.left: 18
|
||||
margin.bottom: 60
|
||||
|
||||
Label
|
||||
text: |
|
||||
Show the most recent
|
||||
Message of the Day
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 40
|
||||
margin.left: 13
|
||||
margin.right: 13
|
||||
|
||||
// ok button
|
||||
Button
|
||||
text: Ok
|
||||
size: 43 20
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.right: 10
|
||||
margin.bottom: 13
|
||||
onClick: function(self) self.parent:destroy() end
|
Reference in New Issue
Block a user