-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
265 changed files
with
36,334 additions
and
610 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
SmallScrollBar < UIScrollBar | ||
orientation: vertical | ||
margin-bottom: 1 | ||
step: 20 | ||
width: 8 | ||
image-source: /images/ui/scrollbar | ||
image-clip: 39 0 13 65 | ||
image-border: 1 | ||
pixels-scroll: true | ||
|
||
UIButton | ||
id: decrementButton | ||
anchors.top: parent.top | ||
anchors.left: parent.left | ||
image-source: /images/ui/scrollbar | ||
image-clip: 0 0 13 13 | ||
image-color: #ffffffff | ||
size: 8 8 | ||
$hover: | ||
image-clip: 13 0 13 13 | ||
$pressed: | ||
image-clip: 26 0 13 13 | ||
$disabled: | ||
image-color: #ffffff66 | ||
|
||
UIButton | ||
id: incrementButton | ||
anchors.bottom: parent.bottom | ||
anchors.right: parent.right | ||
size: 8 8 | ||
image-source: /images/ui/scrollbar | ||
image-clip: 0 13 13 13 | ||
image-color: #ffffffff | ||
$hover: | ||
image-clip: 13 13 13 13 | ||
$pressed: | ||
image-clip: 26 13 13 13 | ||
$disabled: | ||
image-color: #ffffff66 | ||
|
||
UIButton | ||
id: sliderButton | ||
anchors.centerIn: parent | ||
size: 8 11 | ||
image-source: /images/ui/scrollbar | ||
image-clip: 0 26 13 13 | ||
image-border: 2 | ||
image-color: #ffffffff | ||
$hover: | ||
image-clip: 13 26 13 13 | ||
$pressed: | ||
image-clip: 26 26 13 13 | ||
$disabled: | ||
image-color: #ffffff66 | ||
|
||
Label | ||
id: valueLabel | ||
anchors.fill: parent | ||
color: white | ||
text-align: center |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GameButtonsWindow < MiniWindow | ||
height: 26 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Module | ||
name: client_mods | ||
description: Mod loader | ||
author: OTClient Team | ||
website: https://github.com/mehah/otclient | ||
sandboxed: true | ||
load-later: | ||
- client_profiles | ||
- game_buttons | ||
- game_itemselector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
local settings = {} | ||
ChangedProfile = false | ||
|
||
function init() | ||
connect(g_game, { | ||
onGameStart = online, | ||
onGameEnd = offline | ||
}) | ||
|
||
end | ||
|
||
function terminate() | ||
disconnect(g_game, { | ||
onGameStart = online, | ||
onGameEnd = offline | ||
}) | ||
end | ||
|
||
-- loads settings on character login | ||
function online() | ||
ChangedProfile = false | ||
|
||
-- startup arguments has higher priority than settings | ||
local index = getProfileFromStartupArgument() | ||
if index then | ||
setProfileOption(index) | ||
end | ||
|
||
load() | ||
|
||
if not index then | ||
setProfileOption(getProfileFromSettings() or 1) | ||
end | ||
|
||
-- create main settings dir | ||
if not g_resources.directoryExists("/settings/") then | ||
g_resources.makeDir("/settings/") | ||
end | ||
|
||
-- create profiles dirs | ||
for i=1,10 do | ||
local path = "/settings/profile_"..i | ||
|
||
if not g_resources.directoryExists(path) then | ||
g_resources.makeDir(path) | ||
end | ||
end | ||
end | ||
|
||
function setProfileOption(index) | ||
local currentProfile = g_settings.getNumber('profile') | ||
currentProfile = tostring(currentProfile) | ||
index = tostring(index) | ||
|
||
if currentProfile ~= index then | ||
ChangedProfile = true | ||
return modules.client_options.setOption('profile', index) | ||
end | ||
|
||
end | ||
|
||
-- load profile number from settings | ||
function getProfileFromSettings() | ||
-- settings should save per character, return if not online | ||
if not g_game.isOnline() then return end | ||
|
||
local index = g_game.getCharacterName() | ||
local savedData = settings[index] | ||
|
||
return savedData | ||
end | ||
|
||
-- option to launch client with hardcoded profile | ||
function getProfileFromStartupArgument() | ||
local startupOptions = string.split(g_app.getStartupOptions(), " ") | ||
if #startupOptions < 2 then | ||
return false | ||
end | ||
|
||
for index, option in ipairs(startupOptions) do | ||
if option == "--profile" then | ||
local profileIndex = startupOptions[index + 1] | ||
if profileIndex == nil then | ||
return g_logger.info("Startup arguments incomplete: missing profile index.") | ||
end | ||
|
||
g_logger.info("Startup options: Forced profile: "..profileIndex) | ||
-- set value in options | ||
return profileIndex | ||
end | ||
end | ||
|
||
return false | ||
end | ||
|
||
-- returns string path ie. "/settings/1/actionbar.json" | ||
function getSettingsFilePath(fileNameWithFormat) | ||
local currentProfile = g_settings.getNumber('profile') | ||
|
||
return "/settings/profile_"..currentProfile.."/"..fileNameWithFormat | ||
end | ||
|
||
function offline() | ||
onProfileChange(true) | ||
end | ||
|
||
-- profile change callback (called in options), saves settings & reloads given module configs | ||
function onProfileChange(offline) | ||
if not offline then | ||
if not g_game.isOnline() then return end | ||
-- had to apply some delay | ||
scheduleEvent(collectiveReload, 100) | ||
end | ||
|
||
local currentProfile = g_settings.getNumber('profile') | ||
local index = g_game.getCharacterName() | ||
|
||
if index then | ||
settings[index] = currentProfile | ||
save() | ||
end | ||
end | ||
|
||
-- collection of refresh functions from different modules | ||
function collectiveReload() | ||
modules.game_topbar.refresh(true) | ||
modules.game_actionbar.refresh(true) | ||
modules.game_bot.refresh() | ||
end | ||
|
||
-- json handlers | ||
function load() | ||
local file = "/settings/profiles.json" | ||
if g_resources.fileExists(file) then | ||
local status, result = pcall(function() | ||
return json.decode(g_resources.readFileContents(file)) | ||
end) | ||
if not status then | ||
return onError( | ||
"Error while reading profiles file. To fix this problem you can delete storage.json. Details: " .. | ||
result) | ||
end | ||
settings = result | ||
end | ||
end | ||
|
||
function save() | ||
local file = "/settings/profiles.json" | ||
local status, result = pcall(function() return json.encode(settings, 2) end) | ||
if not status then | ||
return onError( | ||
"Error while saving profile settings. Data won't be saved. Details: " .. | ||
result) | ||
end | ||
if result:len() > 100 * 1024 * 1024 then | ||
return onError( | ||
"Something went wrong, file is above 100MB, won't be saved") | ||
end | ||
g_resources.writeFileContents(file, result) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Module | ||
name: client_profiles | ||
description: Client profiles | ||
author: Vithrax | ||
website: discord_Vithrax#5814 | ||
autoload: true | ||
reloadable: false | ||
scripts: [ profiles ] | ||
sandboxed: true | ||
@onLoad: init() | ||
@onUnload: terminate() |
Oops, something went wrong.