mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 04:24:54 +02:00
add a new folder structure redesign organized by packages
This commit is contained in:
57
packages/mainmenu/entergame.lua
Normal file
57
packages/mainmenu/entergame.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
function EnterGame_connectToLoginServer()
|
||||
-- create login protocol
|
||||
local protocolLogin = ProtocolLogin.new()
|
||||
|
||||
-- used to recreate enter game window
|
||||
local recreateEnterGame = function()
|
||||
loadUI("ui/entergamewindow")
|
||||
end
|
||||
|
||||
-- display loading message box
|
||||
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
||||
|
||||
-- cancel loading callback
|
||||
loadBox.onCancel = function()
|
||||
-- cancel protocol and reacreate enter game window
|
||||
protocolLogin:cancel()
|
||||
recreateEnterGame()
|
||||
end
|
||||
|
||||
-- error callback
|
||||
protocolLogin.onError = function(error)
|
||||
-- destroy loading message box
|
||||
loadBox:destroy()
|
||||
|
||||
-- display error message
|
||||
local errorBox = displayErrorBox("Login Error", error)
|
||||
|
||||
-- cancel protocol and reacreate enter game window
|
||||
self.cancel()
|
||||
errorBox.onOk = recreateEnterGame
|
||||
end
|
||||
|
||||
-- motd callback
|
||||
protocolLogin.onMotd = function(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)
|
||||
|
||||
-- cancel protocol and reacreate enter game window
|
||||
self.cancel()
|
||||
motdBox.onOk = recreateEnterGame
|
||||
end
|
||||
|
||||
-- get account and password then login
|
||||
local enterGameWindow = rootUI:child("enterGameWindow")
|
||||
local account = enterGameWindow:child("accountNameTextEdit").text
|
||||
local password = enterGameWindow:child("passwordTextEdit").text
|
||||
protocolLogin:login(account, password)
|
||||
|
||||
-- destroy enter game window
|
||||
enterGameWindow:destroy()
|
||||
end
|
||||
|
16
packages/mainmenu/init.lua
Normal file
16
packages/mainmenu/init.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
require 'entergame'
|
||||
|
||||
function initializeApplication()
|
||||
mainMenu = loadUI("ui/mainmenu")
|
||||
end
|
||||
|
||||
function terminateApplication()
|
||||
App.exit()
|
||||
end
|
||||
|
||||
-- here is where everything starts
|
||||
if not initialized then
|
||||
initializeApplication()
|
||||
App.onClose = terminateApplication
|
||||
initialized = true
|
||||
end
|
9
packages/mainmenu/package.otml
Normal file
9
packages/mainmenu/package.otml
Normal file
@@ -0,0 +1,9 @@
|
||||
title: Main menu
|
||||
description: Used to create the main menu
|
||||
author: otclient
|
||||
version: 1
|
||||
website: https://github.com/edubart/otclient
|
||||
enabled: true
|
||||
dependencies: [core]
|
||||
script: init.lua
|
||||
|
BIN
packages/mainmenu/ui/background.png
Normal file
BIN
packages/mainmenu/ui/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
53
packages/mainmenu/ui/entergamewindow.otml
Normal file
53
packages/mainmenu/ui/entergamewindow.otml
Normal file
@@ -0,0 +1,53 @@
|
||||
window#enterGameWindow
|
||||
title: Enter Game
|
||||
size: 236 178
|
||||
anchor.centerIn: parent
|
||||
lockOnLoad: true
|
||||
|
||||
%label
|
||||
text: Account name
|
||||
position: 18 33
|
||||
|
||||
%label
|
||||
text: "Password:"
|
||||
position: 18 62
|
||||
|
||||
%label
|
||||
text: |
|
||||
If you don't have
|
||||
an account yet
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 87 18
|
||||
|
||||
%button.notImplemented
|
||||
text: Create Account
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin: 94 18
|
||||
|
||||
%button.small
|
||||
text: Ok
|
||||
anchors.bottomRight: parent.bottomRight
|
||||
margin: 10 66
|
||||
onClick: EnterGame_connectToLoginServer()
|
||||
|
||||
%button.small.closeParent
|
||||
text: Cancel
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
margin: 10 13
|
||||
|
||||
%textEdit#accountNameTextEdit
|
||||
text: tibialua0
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin: 32 18
|
||||
|
||||
%textEdit#passwordTextEdit
|
||||
text: lua123456
|
||||
text-hidden: true
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin: 61 18
|
||||
|
54
packages/mainmenu/ui/infowindow.otml
Normal file
54
packages/mainmenu/ui/infowindow.otml
Normal file
@@ -0,0 +1,54 @@
|
||||
%window#infoWindow
|
||||
title: Info
|
||||
size: 244 221
|
||||
anchor.centerIn: parent
|
||||
lockOnLoad: true
|
||||
|
||||
%panel.flat
|
||||
size: 208 129
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 32 18
|
||||
|
||||
%label
|
||||
align: center
|
||||
text: |-
|
||||
OTClient
|
||||
Version 0.2.0
|
||||
Created by edubart
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
margin.top: 20
|
||||
|
||||
%element.bottomSeparator
|
||||
size: 190 2
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 83 9
|
||||
|
||||
%label
|
||||
text: Official Website
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
margin: 14 9
|
||||
|
||||
%button
|
||||
text: Github Page
|
||||
size: 80 22
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
margin: 9
|
||||
|
||||
%element.bottomSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 40 13
|
||||
|
||||
%button.closeParent
|
||||
text: Ok
|
||||
size: 43 20
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 191 188
|
||||
|
37
packages/mainmenu/ui/mainmenu.otml
Normal file
37
packages/mainmenu/ui/mainmenu.otml
Normal file
@@ -0,0 +1,37 @@
|
||||
%panel#mainBackground
|
||||
image: { source: background.png; antialised: true }
|
||||
anchor.fill: parent
|
||||
|
||||
%panel#mainMenuPanel.flat
|
||||
size: 117 171
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
margin: 70 60
|
||||
|
||||
button
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 6
|
||||
|
||||
%button.first
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 16
|
||||
text: Enter Game
|
||||
onClick: loadUI("entergamewindow")
|
||||
|
||||
%button.notImplemented
|
||||
text: Access Account
|
||||
|
||||
%button
|
||||
text: Options
|
||||
onClick: loadUI("optionswindow")
|
||||
|
||||
%button
|
||||
text: Info
|
||||
onClick: loadUI("infowindow")
|
||||
|
||||
%button
|
||||
text: Exit
|
||||
onClick: terminateApplication()
|
||||
|
82
packages/mainmenu/ui/optionswindow.otml
Normal file
82
packages/mainmenu/ui/optionswindow.otml
Normal file
@@ -0,0 +1,82 @@
|
||||
%window#optionsWindow
|
||||
title: Options
|
||||
size: 286 262
|
||||
anchor.centerIn: parent
|
||||
lockOnLoad: true
|
||||
|
||||
panel
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin.left: 18
|
||||
margin.top: 3
|
||||
height: 30
|
||||
|
||||
button
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin.top: 3
|
||||
onClick: displayErrorBox("Error", "Not implemented yet")
|
||||
|
||||
label
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin.top: 99
|
||||
|
||||
%panel
|
||||
anchors.top: parent.top
|
||||
margin.top: 29
|
||||
|
||||
%button { text: General }
|
||||
%label { text: "Change general\ngame options" }
|
||||
|
||||
%panel
|
||||
%button { text: Graphics }
|
||||
%label { text: "Change graphics and\nperformance settings" }
|
||||
|
||||
%panel
|
||||
%button { text: Console }
|
||||
%label { text: Customise the console }
|
||||
|
||||
%panel
|
||||
%button { text: Hotkeys }
|
||||
%label { text: Edit your hotkey texts }
|
||||
|
||||
%element.horizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 97 18
|
||||
|
||||
%panel
|
||||
anchors.top: ~
|
||||
anchors.bottom: parent.bottom
|
||||
margin.top: 29
|
||||
|
||||
%button
|
||||
text: Motd
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 60 18
|
||||
|
||||
%label
|
||||
text: |
|
||||
Show the most recent
|
||||
Message of the Day
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 56 117
|
||||
|
||||
%element.horizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 40 13
|
||||
|
||||
%button.closeParent
|
||||
text: Ok
|
||||
size: 43 20
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 13 10
|
||||
|
Reference in New Issue
Block a user