-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pertex - Logo and Desktop Icon, DateTime, endWaitDiv, Filewatcher Core #1239
Conversation
Submitted by Pertex
Allows displaying #endWaitLink when the text command prompt is hidden
We are assuming these two images did not come from https://de.icons8.com/. From **Editor\My Project\AssemblyInfo.vb:** ``` All Icons by https://de.icons8.com/ are licensed under CC BY-ND 3.0. ```
Submitted by Pertex Adds two hard-coded DateTime String Functions: - `CurrentDate()` - `CurrentTime()`
Include UTC as well as local time
Now => UtcNow in Utc functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the tweaked logo. I've left comments on a bunch of other changes here.
These kinds of changes would be much easier to review as separate PRs. There are 4 independent changes here, so could you put these in 4 separate PRs please - that way they can be merged and/or discussed separately.
m_fileWatcher.EnableRaisingEvents = True | ||
m_fileWatcherQuest = New System.IO.FileSystemWatcher(Application.StartupPath + "\Core", "*.aslx") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely convinced of this change, I don't think anyone should be editing core library .aslx
files directly within the Quest app directory itself, while the editor is loaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was all @Pertex. (Not sure if he gets notified without tagging him here.)
We never really discussed this one; so, I don't know what his reason was. I'm sure he'll be along soon, though.
EDIT
I've left comments on a bunch of other changes here.
Those didn't show up in my notifications for some reason, and I replied to this before I saw the rest. (I thought you meant in the other pull requests.) Disregard this. We'll do these separately, omitting the ones you noted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added these things especially for quest developers, when you need to quickly edit core files. An addition, but not important for the normal user.
@@ -421,6 +426,7 @@ Public Class Editor | |||
Private Function Save(filename As String) As Boolean | |||
Try | |||
m_fileWatcher.EnableRaisingEvents = False | |||
m_fileWatcherQuest.EnableRaisingEvents = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless... if m_fileWatcherQuest
is only monitoring the Quest app directory, there's no need to deactivate it here when a game file is saved
@@ -1021,6 +1028,14 @@ Public Class Editor | |||
Reload() | |||
End Sub | |||
|
|||
Private Sub m_fileWatcherQuest_Changed(sender As Object, e As System.IO.FileSystemEventArgs) Handles m_fileWatcherQuest.Changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicates the regular file watcher, so you could use the same event handler function here (though I would rename it). Although, if you were monitoring the app directory, you would want the banner to say that (right now it will tell you that the game's .aslx
file has changed, when it hasn't).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My knowledge is not sufficient for this
public static string CurrentDate() | ||
{ | ||
DateTime localDate = DateTime.Now; | ||
return localDate.ToShortDateString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These return locale-specific strings i.e. the format will depend on the locale of the machine. That may be fine for running on desktop, but on the web it will always be the locale of the server.
Also, because you've only provided these locale-specific versions, there's no way for a game to reliably process the date (if it wanted to extract the current month for example - how does it know where in the string that is).
So this feature needs a lot more thought before we can add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, we've also racked our brains over it. We can only get the current local time via the browser and Javascript. And since the communication between Quest and Javascript is not easy, I first created two simple functions that a developer can already do something with. The functions and results are not wrong, you can work with them. I use them, for example, to determine the playing time from the start of a game to the end in days.
Perhaps you have a tip for us on how we can send data from Javascript to Quest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would use ASLEvent
for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were concerns about this because there were difficulties with ASLEvent, timing problems I think. Let me discuss this again with KV plz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These return locale-specific strings i.e. the format will depend on the locale of the machine. That may be fine for running on desktop, but on the web it will always be the locale of the server.
That's right, we've also racked our brains over it. We can only get the current local time via the browser and Javascript.
That's why I added the UTC counterparts. We didn't realize this at first, and we'd added time and date attributes to the game object in start script. After we compared our online transcripts one day, we noticed the time was that of the server, and I removed the bits from the Core library, added the UTC functions, and left it in the source code so people could use it if they wanted it.
If I were to use this in a game:
Example game
Do You Have the Time (For the Quest 5.9 testing build only).zip
<!--Saved by Quest 5.9.9123.20989-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Do You Have the Time?">
<gameid>eda4b815-d1ee-4203-b442-d0559f12654d</gameid>
<version>1.0</version>
<firstpublished>2024</firstpublished>
<feature_advancedscripts />
<attr name="autodescription_youarein_useprefix" type="boolean">false</attr>
<attr name="autodescription_description" type="int">2</attr>
<attr name="autodescription_youcango" type="int">4</attr>
<attr name="autodescription_youcansee" type="int">3</attr>
<autodescription_description_newline />
<inituserinterface type="script">
SetUpInitTimeAndDate
</inituserinterface>
<start type="script">
SetUpStartTimeAndDate
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<isroom />
<description><![CDATA[<br/>The current time is {=DictionaryItem (GetCurrentTime(),"time")}{if not game.islocaltime: UTC}, and the date is {=DictionaryItem (GetCurrentDate(), "date")}.<br/><br/>JavaScript Date(): <span id="js-date-{game.currentturnoutputsection}"><img src="{=GetFileURL("foo")}" onerror="updateJsDateDiv('{game.currentturnoutputsection}');$(this).remove();"/>loading...</span><br/><br/>You started this game at {game.starttime} on {game.startdate}.<br/><br/>You loaded the current session at {game.inittime} on {game.initdate}.<br/><br/>Wait until the time changes and type {command:LOOK} to test this room description.<br/><br/>Use the {command:SAVE} command, then load the saved game to test the start and init time and date attributes on the game object.<br/><br/>]]></description>
<alias>Time and Date Testing Grounds</alias>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<function name="IsDesktop" type="boolean">
return (GetFileURL("BaseURI").StartsWith("quest"))
</function>
<function name="GetCurrentTime" type="dictionary">
if (IsDesktop()) {
return (QuickParams ("time", CurrentTime(),"local", true))
}
return (QuickParams ("time", CurrentUtcTime(),"local", false))
</function>
<function name="GetCurrentDate" type="dictionary">
if (IsDesktop()) {
return (QuickParams ("date", CurrentDate(), "local", true))
}
return (QuickParams ("date", CurrentUtcDate(), "local", false))
</function>
<function name="SetJsDate" parameters="jsdate"><![CDATA[
game.changedjsdate => {
JS.updateJsDateDiv (game.currentturnoutputsection, game.jsdate)
}
game.jsdate = jsdate
]]></function>
<function name="SetUpInitTimeAndDate">
timedict = GetCurrentTime()
game.inittime = DictionaryItem (timedict, "time")
game.islocaltime = DictionaryItem (timedict, "local")
game.initdate = DictionaryItem (GetCurrentDate(), "date")
JS.eval("window.updateJsDateDiv = function(idsuffix, s=Date().toString()) {$('#js-date-' + idsuffix).html(s);};")
JS.eval("window.setJsDate = function() { canSendCommandBak = canSendCommand; canSendCommand = true; ASLEvent ('SetJsDate', Date().toString()); canSendCommand = canSendCommandBak;};")
JS.setJsDate()
</function>
<function name="SetUpStartTimeAndDate">
timedict = GetCurrentTime()
game.starttime = DictionaryItem (timedict, "time")
game.startdate = DictionaryItem (GetCurrentDate(), "date")
</function>
</asl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not about the time zone, but about the time format.
For example on a machine in the US the short format for today's date is 12/27/2024
, but for the UK it's 27/12/2024
.
This is why I'm hesitant to build this in as native Quest functions because there's a lot to cover. And all of this stuff exists in JavaScript already so why not just use it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see where you're coming from. (I also learned something. I thought your format was 2024/12/27
, and I've been writing the date that way in attempt to make it easier for everyone across the pond for quite a while, haha.)
I threw the ASLEvent
method into that example game, too. There are basically two (and a half) things to cover when using that method:
If the script is running in response to a command, ASLEvent
will not fire online because canSendCommand
will be false
. I have a dirty (probably mostly unnecessary) hack in the example where I back that value up, set the variable to true
, then change it back after calling ASLEvent
, but I don't know how dangerous that is -- haven't had problems with it online as of yet.
The delay between JS and Quest means we can't use things like this:
game.questplatform = "notset"
JS.whereAmI()
msg(game.questplatform)
That will result in "notset" every time, because it depends on ASLEvent
to set game.questplatform
:
function whereAmI(){
ASLEvent("WhereAmI", "' + platform + '");
}
<function name="WhereAmI" parameters="platform">
game.questplatform = platform
</function>
The best way to handle that delay is to use a change script, but that will fire after the script calling JS.whereAmI()
, and most Quest authors don't quite grasp the concept of non-blocking scripts, let alone all this. (Not being mean here. I just recently learned what little I know about this stuff, myself.)
Also, to exacerbate things, the delay has ranged from 50ms to 2000ms when a few of us tested this a few months ago.
This also has me thinking about my JS function to get the time and date for the log entries when writing the log to a file! I won't derail this issue with that, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a sleep function in Quest so we could use it in a loop waiting for the ASLEvent?
|
Thanks. For number 4 I think we just leave this for now. |
Submitted by @Pertex
CurrentDate
andCurrentTime