Skip to content

Commit

Permalink
fix: showing the error dialog in the main menu
Browse files Browse the repository at this point in the history
FossilOrigin-Name: b96ab6ec0c8dbaacf2487927f275e036ed5136901cc124d616b4c5ad5bba885e
  • Loading branch information
thindil committed Nov 8, 2024
1 parent 6a7b7de commit aa9250d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ui/errordialog.nim
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ proc showDialog(dialog: string; parentFrame: string = ".gameframe";
$relativeX & " -rely " & $relativeY)
tclEval(script = "raise " & dialog)

proc showError*(message: string; e: ref Exception = getCurrentException()): TclResults {.discardable,
raises: [], tags: [WriteIOEffect, TimeEffect, RootEffect], contractual.} =
proc showError*(message: string; e: ref Exception = getCurrentException(
)): TclResults {.discardable, raises: [], tags: [WriteIOEffect, TimeEffect,
RootEffect], contractual.} =
## Show the error dialog with the message containing technical details about the issue
##
## * message - the message to show in the error dialog
Expand All @@ -121,8 +122,8 @@ proc showError*(message: string; e: ref Exception = getCurrentException()): TclR
let
parentName = (if tclEval2(script = "winfo exists .gameframe") ==
"1": ".gameframe" else: ".")
errorDialog = createDialog(name = ".errordialog", title = message,
parentName = parentName)
errorDialog = createDialog(name = ".errordialog",
title = "Error!Error!Error!", parentName = parentName)
var errorLabel = errorDialog & ".general"
tclEval(script = "ttk::label " & errorLabel & " -wraplength 650 -text {Oops, something bad happened and the game has encountered an error. Please, remember what you were doing before the error and report this problem at:}")
tclEval(script = "grid " & errorLabel & " -padx 5 -sticky w")
Expand Down Expand Up @@ -163,5 +164,6 @@ proc showError*(message: string; e: ref Exception = getCurrentException()): TclR
tclEval(script = "grid " & errorLabel & " -padx {5 0} -pady {0 5} -sticky w")
tclEval(script = "grid " & yScroll & " -sticky ns -pady 5 -padx {0 5} -pady {0 5} -row 0 -column 1")
tclEval(script = "grid " & errorFrame & " -pady {0 5}")
showDialog(dialog = errorDialog, relativeX = 0.1, relativeY = 0.05)
showDialog(dialog = errorDialog, parentFrame = parentName, relativeX = 0.1,
relativeY = 0.05)
return tclOk

0 comments on commit aa9250d

Please sign in to comment.