-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea/ export-ignore | ||
PlayedAll.iml export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
README.md export-ignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/workspace.xml | ||
.idea/tasks.xml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Boris Rosenow | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="LUA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
PlayedAll = {} | ||
PlayedAll.name = "PlayedAll" | ||
PlayedAll.version = "0.1" | ||
|
||
local savedVariables | ||
local charName = GetUnitName("player") | ||
|
||
local function formatCharNames(charNames) | ||
local allNames = '' | ||
local index, name = next(charNames, nil) | ||
while index do | ||
local nextIndex, nextName = next(charNames, index) | ||
local isFirst = string.len(allNames) == 0 | ||
if not isFirst then | ||
allNames = allNames .. (nextIndex and ', ' or GetString(SI_PLAYEDALL_AND)) | ||
end | ||
allNames = allNames .. name | ||
index, name = nextIndex, nextName | ||
end | ||
return allNames | ||
end | ||
|
||
local function displayTotalPlayedTime(charNames, time) | ||
local playedTime = ZO_FormatTime(time, TIME_FORMAT_STYLE_DESCRIPTIVE, TIME_FORMAT_PRECISION_SECONDS) | ||
CHAT_SYSTEM:AddMessage(zo_strformat(SI_CHAT_MESSAGE_PLAYED_TIME, formatCharNames(charNames), playedTime)) | ||
end | ||
|
||
local function getSavedVariables() | ||
local username = GetDisplayName() | ||
local playedAllVars = _G['PlayedAllVars'] | ||
if not playedAllVars then | ||
playedAllVars = {} | ||
_G['PlayedAllVars'] = playedAllVars | ||
end | ||
local savedVariables = PlayedAllVars[username] | ||
if not savedVariables then | ||
savedVariables = {} | ||
PlayedAllVars[username] = savedVariables | ||
end | ||
return savedVariables | ||
end | ||
|
||
local function updatePlayedTime() | ||
savedVariables[charName] = GetSecondsPlayed() | ||
end | ||
|
||
local function setupHooks() | ||
ZO_PreHook("ReloadUI", updatePlayedTime) | ||
|
||
ZO_PreHook("Logout", updatePlayedTime) | ||
|
||
ZO_PreHook("SetCVar", updatePlayedTime) | ||
|
||
ZO_PreHook("Quit", updatePlayedTime) | ||
end | ||
|
||
local function initialize() | ||
local playedCommand = GetString(SI_SLASH_PLAYED_TIME) | ||
local normalPlayed = SLASH_COMMANDS[playedCommand] | ||
|
||
savedVariables = getSavedVariables() | ||
updatePlayedTime() | ||
|
||
SLASH_COMMANDS[playedCommand] = function (args) | ||
updatePlayedTime() | ||
if args ~= 'all' then | ||
normalPlayed(args) | ||
return | ||
end | ||
|
||
local charNames = {} | ||
local totalPlayed = 0 | ||
|
||
for name, time in pairs(savedVariables) do | ||
table.insert(charNames, name) | ||
totalPlayed = totalPlayed + time | ||
end | ||
|
||
displayTotalPlayedTime(charNames, totalPlayed) | ||
end | ||
|
||
setupHooks() | ||
end | ||
|
||
local function onAddOnLoaded(_, addonName) | ||
if addonName ~= PlayedAll.name then return end | ||
initialize() | ||
end | ||
|
||
-- register addon load | ||
EVENT_MANAGER:RegisterForEvent(PlayedAll.name, EVENT_ADD_ON_LOADED, onAddOnLoaded) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Title: PlayedAll | ||
## Description: Adds a parameter to the /played command to display the played time of all your characters. | ||
## APIVersion: 100011 | ||
## SavedVariables: PlayedAllVars | ||
|
||
lang/en.lua | ||
lang/$(language).lua | ||
|
||
PlayedAll.lua |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# PlayedAll | ||
|
||
PlayedAll is a simple addon for the MMORPG Elder Scrolls Online. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ZO_CreateStringId('SI_PLAYEDALL_AND', ' und ') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ZO_CreateStringId('SI_PLAYEDALL_AND', ' and ') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ZO_CreateStringId('SI_PLAYEDALL_AND', ' et ') |