Download
(4 Kb)
Download
Updated: 09/07/19 07:14 PM
Pictures
File Info
Compatibility:
Scalebreaker (5.1.5)
Updated:09/07/19 07:14 PM
Created:06/07/19 02:25 AM
Monthly downloads:35
Total downloads:2,888
Favorites:3
MD5:
Stopwatch
Version: 1.1
by: Gordias, Baertram
Description

Stopwatch is a simple add-on that places a label on the screen as a stopwatch. It displays the amount of time that elapsed between its activation and deactivation. The keybindings to activate and reset it can be set under General settings from the Controls menu of the game. Both the label color and the label font can be changed from the add-on settings.

Credits
This add-on uses LibAddonMenu by sirinsidiator and Seerah. This add-on is requested by @Zeitah.
1.1 - Font size and character-wide settings options are added (thanks to Baertram for reviewing and providing the code)
1.01 - API is updated to 100028
Archived Files (2)
File Name
Version
Size
Uploader
Date
1.01
3kB
Gordias
08/31/19 09:00 AM
1.0
3kB
06/07/19 02:25 AM


Post A Reply Comment Options
Unread 09/10/19, 07:35 PM  
crazmadsci

Forum posts: 0
File comments: 3
Uploads: 0
Any chance you could add a hotkey for essentially a lap? A temporary save but not a stop? This would allow us to time multiple events in combat without losing any data.

Love the work btw.
Report comment to moderator  
Reply With Quote
Unread 09/08/19, 06:25 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4979
File comments: 6039
Uploads: 78
Thank you. No need to add me, just asked for the feature and helped to explain how to achieve it
Report comment to moderator  
Reply With Quote
Unread 09/07/19, 07:23 PM  
Gordias
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 12
Uploads: 4
Thank you for reviewing and providing updates for the code! I've updated the add-on to support character wide settings according to your instructions above and also added the font size option, though this option required the predefined fonts to be changed with font types like bold, medium, antique, etc. I also set you as an author for the add-on as you had already written parts of it.
Report comment to moderator  
Reply With Quote
Unread 09/03/19, 06:25 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4979
File comments: 6039
Uploads: 78
This comes in handy! Many thanks.
Could you maybe add a font size LAM slider as well? This would be great as I'd like the stopwatch to be on one char at the bottom left near the caht (small) and on the other char in the middle of the screen, top and big.

SavedVariables - Not account wide?
In order to setup the stopwatch on different characters differently, could you maybe change the SavedVariables to character and not account wide?
Or maybe both selectable via settings menu (LAM dropdown box saving the settings in a new savedvariables table (not your current one! Account wide) and if you select account wide from the dropdown box it will load your settings from your current savedvariables table account wide. If you choose character it will use ZO_SavedVars:NewCharacterId instead.

To add a second SavedVariables table you can use in your manifest txt file:
Code:
## SavedVariables: StopwatchVars StopWatchVars_AccountSettings
This will add a global table StopWatchVars_AccountSettings for your SavedVariables where you only store the account wide settings like "Use account wide" or "Use character settings" etc.
All other settings will remain in your table StopWatchVars then!


In your StopWatch tablea dd the table defaultAccount:
Lua Code:
  1. -- Default settings for Account SavedVariables
  2.     defaultAccount = {
  3.         --1: Account wide
  4.         --2: Each character
  5.         saveMode = 1, --use Account Wide settings as default
  6.     },
  7.  
  8.     -- Default settings for SavedVariables
  9.     default = {
  10.         offsetX = -100,
  11.         offsetY = 200,
  12.         labelColor = {197/255, 194/255, 158/255, 1},
  13.         labelFont = "ZoFontAnnounceMedium",
  14.     },
And in your code where you load the SavedVariables you can use something like this:
Lua Code:
  1. -- Load saved variables for Account settings
  2.     Stopwatch.savedVariablesAccount = ZO_SavedVars:NewAccountWide("StopWatchVars_AccountSettings", Stopwatch.variableVersion, nil, Stopwatch.defaultAccount, GetWorldName())
  3.     --Use Accoutn wide settings?
  4.     if Stopwatch.savedVariablesAccount.saveMode == 1 then
  5.         -- Load saved variables
  6.         Stopwatch.savedVariables = ZO_SavedVars:NewAccountWide("StopwatchVars", Stopwatch.variableVersion, nil, Stopwatch.default, GetWorldName())
  7.     else
  8.         Stopwatch.savedVariables = ZO_SavedVars:NewCharacterIdSettings("StopwatchVars", Stopwatch.variableVersion, nil, Stopwatch.default, GetWorldName())
  9.     end
-> I've added GetWorldName() at the end to make the SV save the servername as well on top so you can have different settings on the same accounts on different server (if you do not like this just remove the last parameter again).

Your LAM dropdownbox then just should use the two possible entries for the selection:
Lua Code:
  1. -- LAM Options
  2.     optionsTable = {
  3.         {
  4.             type = "header",
  5.             name = "General Settings",
  6.             width = "full", --or "half" (optional)
  7.         },
  8.         {
  9.             type = "dropdown",
  10.             name = "Save mode",
  11.             tooltip = "Choose if you want to save Account wide or settings for each character",
  12.             choices = {
  13.                 [1] = "Account wide",
  14.                 [2] = "Each character",
  15.             },
  16.             choicesValues = {
  17.                 [1] = 1,
  18.                 [2] = 2,
  19.             },
  20.             getFunc = function() return Stopwatch.savedVariablesAccount.saveMode end,
  21.             setFunc = function(var)
  22.                 Stopwatch.savedVariablesAccount.saveMode = var
  23.                 end,
  24.             width = "full",
  25.             default = Stopwatch.defaultAccount.saveMode,
  26.             requiresReload = true,
  27.         },
  28.         {
  29.             type = "button",
  30.             name = "Chang
  31. ...

btw: I've removed the numbers in front of your LAM table entries (1 to 6). You do not need them as you would need to renumber all if you want to insert one entry...
Just leave them empty and the table will do this for you automatically.
-> If you need to reference one entry in the table use the LAM's control reference = "..." instead!

About libraries in your addon:
Please do NOT use LibStub anymore where not needed.
LiBStub is getting obsolete as Zos ahs implemented it's own version tracking via the txt files tag ## AddOnVersion:
So old and new libraries will one day get rid of LibStub.
Better prepare your addon now and change calls to LibStub to use the global variable of the libraries, e.g. LibAddonMenu2, instead!

And:
Please do not put LibStub in your addon's manifest txt file ## OptionalDependsOn or ## DependsOn!
Your addon does NOT need LibStub. It's the libraries which use and need LibStub (And most don't even need it anymore as described above). So if one txt file would have ## OptionalDependsOn: LibStub or ## DependsOn: LibStub this would be the library's txt file, and NOT your addon's txt file.

So please change this (there are 2 spaces after LibAddonMenu-2.0, which most likely will not register the following addons/libraries):
Code:
## DependsOn: LibAddonMenu-2.0  LibStub
To this:
Code:
## DependsOn: LibAddonMenu-2.0
and this in your addon's lua file of the LAM settings menu:
Code:
-- Get reference to the LibAddonMenu-2.0 library table
local LAM = LibStub:GetLibrary("LibAddonMenu-2.0")
to this:
Code:
-- Get reference to the LibAddonMenu-2.0 library table
local LAM = LibAddonMenu2
The wiki and tutorials were changed to this as well. if you have found the code in another tutorial please tell me where so I can update this as well. Thank you.
Last edited by Baertram : 09/03/19 at 02:11 PM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: