Conversation
PatrykPaluch
left a comment
There was a problem hiding this comment.
Just locking cr. I will look later on this
| [TextArea(10, 20)] | ||
| [SerializeField] private string code; | ||
|
|
||
| public string code; |
There was a problem hiding this comment.
I'm not sure about making it public like that. I think we needs to check if the robot is running to avoid mismatched "code in variable" and actually running code in engine
| public void StopTask() | ||
| { | ||
| StopAllCoroutines(); | ||
| commandQueue.Clear(); | ||
|
|
||
| cancellationTokenSource?.Cancel(); | ||
| cancellationTokenSource?.Dispose(); | ||
| cancellationTokenSource = null; | ||
| } |
There was a problem hiding this comment.
I need to double check this
| catch (OperationCanceledException) | ||
| { | ||
| Debug.Log("[Programmable JsThread] Operation was cancelled"); | ||
| Debug.LogError("Operation was cancelled"); |
There was a problem hiding this comment.
I'm not sure if this is an Error or even a warning - in my opinion just info. Also, previous message was more descriptive
| taskCompletedEvent = new ManualResetEvent(false); | ||
|
|
||
| debugI = staticDebugI++; | ||
| engineLogicInterfaces = GetComponents<IEngineLogic>(); |
There was a problem hiding this comment.
I think about moving this to startTask
Acu1000
left a comment
There was a problem hiding this comment.
This bug occured when I first tried it:
Steps to reproduce:
- Go to saves folder (you can do
Debug.Log(Application.persistentDataPath)) - Delete
JsFilesfolder - Start the game in the
RobotAPIscene, interact with the robot to open the UI - Create a new script (error happens regardless of the script's content)
- Click "Run"
|
I tried running a simple "while true: move forward, rotate 45deg" script and the robot does not seem to move in an octagonal path as expected, but I don't believe this is in the scope of this PR |
| public void RunActiveFile() | ||
| { | ||
| if (IsUiInteractionInvalid("Found no files to execute")) { return; } | ||
| fileManager.RunActiveFile(); | ||
| } | ||
|
|
||
| public void StopActiveFile() | ||
| { | ||
| if (IsUiInteractionInvalid("Found no files to stop")) { return; } | ||
| fileManager.StopActiveFile(); | ||
| } |
There was a problem hiding this comment.
Run/Stop in Canvas should be replace by one button that will change to "Run"/"Stop" depending on running state. Additionally i would add running indicator - just label "running" maybe with timer but timer is not necessary.
keep in mind that program can be stopped by other sources or can finish execution by it self. So you probably need to add some event listeners to Programmable for task start and end.
| @@ -11,7 +11,8 @@ namespace Cosmobot | |||
| { | |||
| public class ProgrammingUi : MonoBehaviour | |||
There was a problem hiding this comment.
Console is not robot specific. When you open robot programming ui, player should see logs for that robot
| public class RobotUiInteractionHandler : MonoBehaviour, IInteractable | ||
| { | ||
| [SerializeField] | ||
| private ProgrammingUiManager programmingUiManager; |
There was a problem hiding this comment.
i think ProgramminUiManager should be SingletonSystem and accessible by Instance static variable (just implement SingletonSystem and replace Awake/Start with override void SystemAwake
| [SerializeField] | ||
| private PlayerCamera playerCamera; |
There was a problem hiding this comment.
im starting to think about implementing GameManager with all that player stuff before continuing with this PR
There was a problem hiding this comment.
Good idea. We'll consider adding it once the current PRs are merged. I believe we can merge this one without it though.
There was a problem hiding this comment.
As I stated in comment to this PR, we should wait until GameManager is merged. This is already an issue, and there are already two PR that make this issue more time consuming. For now GameManager is only new class and one change in Construction script. Implementing GameManager first will be easier and faster, than implementing it afterwards
|
|
||
| private void OnEnable() | ||
| { | ||
| RobotLogger.AddAllLogEventHandler(logManager.CreateLog); |
There was a problem hiding this comment.
ProgrammingUiLogManager is an MonoBehaviour script, so it should register event handler by its own
| } | ||
|
|
||
| public void CreateLog(long time, LogLevel level, string message) | ||
| public void CreateLog(ProgrammableData data, LogEntry logEntry) |
There was a problem hiding this comment.
This function should check if it is necessary to instantiate new ui elements. These are still gameobject and can impact performance. Im not sure how exacly Canvas remeshing/rendering works, but im would prefer not to create new game objects if UI is not visible to user.
You can also just unsubscribe event when UI is closed and subscribe again on OpenUI.
To retrieve all logs that ware logged before opening UI you can use RobotLogger.TryGetRobotLogs function. This will also help whit changing view between robots.
Logs are dynamic so i think its good place for pooling. Create pool of those ProgrammingUiLogEntry GameObjects with some max size (eg. 200). If new logs appear after using up the pool, just reuse the oldest object. Yes, this will limit number of logs visible to player, but its better than spamming and deleting new GameObject indefinitely. Sooner or later we will use pooling so i think its good time and place to implement it. I think i have some universal pooling script i created for other project, DM me and i will send you script.
| public void CreateNewFile() | ||
| { | ||
| fileManager.CreateNewFile("file" + fileManager.GetFileCount() + ".js"); // TEMP | ||
| } |
There was a problem hiding this comment.
if possible this should ask user for file name. Maybe rename button (just "R" for now to keep it small, we will later add icons).
If this is too much coding for this task then ignore this comment, we will probably rewrite entire UI later to UI Elements, so try not to work on Canvas specific stuff too much
There was a problem hiding this comment.
Manual setting of file names is a job for a separate task, no need to worry about it in this PR
| public void CloseUI() | ||
| { | ||
| ChangeUiState(false); | ||
| } |
There was a problem hiding this comment.
if possible add ESC to close UI
|
|
||
| private Programmable robot; | ||
|
|
||
| public string Prompt { get; private set; } = "Press 'E' to interact"; |
There was a problem hiding this comment.
"Press 'E' to program the robot"
or
"Press 'E' to open programming window"
or something like that
|
#137 was merged today, so now you will have conflicts with scenes (as you can see in merge window below). So:
also remember about |
closes #125