summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-07-10 16:44:13 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-07-10 16:44:13 +0200
commitf63602557a2f7320a7e02a3bf7dd9b339efaf4d1 (patch)
tree360f47978854409073718b23a5189b62acea0e9e /src/map-editor/src/Struct/UI.elm
parentcc7e5d48a82eac5d6643702e84a4ed9ac2bb15d3 (diff)
Starting work on the map editor...
Diffstat (limited to 'src/map-editor/src/Struct/UI.elm')
-rw-r--r--src/map-editor/src/Struct/UI.elm139
1 files changed, 139 insertions, 0 deletions
diff --git a/src/map-editor/src/Struct/UI.elm b/src/map-editor/src/Struct/UI.elm
new file mode 100644
index 0000000..447cfc4
--- /dev/null
+++ b/src/map-editor/src/Struct/UI.elm
@@ -0,0 +1,139 @@
+module Struct.UI exposing
+ (
+ Type,
+ Tab(..),
+ Action(..),
+ default,
+ -- Zoom
+ get_zoom_level,
+ reset_zoom_level,
+ mod_zoom_level,
+ -- Tab
+ try_getting_displayed_tab,
+ set_displayed_tab,
+ reset_displayed_tab,
+ to_string,
+ get_all_tabs,
+ -- Navigator
+ try_getting_displayed_nav,
+ set_displayed_nav,
+ reset_displayed_nav,
+ -- Manual Controls
+ has_manual_controls_enabled,
+ -- Previous Action
+ has_focus,
+ get_previous_action,
+ set_previous_action
+ )
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Location
+import Struct.Navigator
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Tab =
+ StatusTab
+ | CharactersTab
+ | SettingsTab
+ | TimelineTab
+
+type Action =
+ UsedManualControls
+ | SelectedLocation Struct.Location.Ref
+ | SelectedCharacter Int
+ | AttackedCharacter Int
+
+type alias Type =
+ {
+ zoom_level : Float,
+ show_manual_controls : Bool,
+ displayed_tab : (Maybe Tab),
+ previous_action : (Maybe Action),
+ displayed_nav : (Maybe Struct.Navigator.Type)
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+default : Type
+default =
+ {
+ zoom_level = 1.0,
+ show_manual_controls = True,
+ displayed_tab = Nothing,
+ previous_action = Nothing,
+ displayed_nav = Nothing
+ }
+
+-- Zoom ------------------------------------------------------------------------
+get_zoom_level : Type -> Float
+get_zoom_level ui = ui.zoom_level
+
+reset_zoom_level : Type -> Type
+reset_zoom_level ui = {ui | zoom_level = 1.0}
+
+mod_zoom_level : Float -> Type -> Type
+mod_zoom_level mod ui = {ui | zoom_level = (mod * ui.zoom_level)}
+
+-- Tab -------------------------------------------------------------------------
+try_getting_displayed_tab : Type -> (Maybe Tab)
+try_getting_displayed_tab ui = ui.displayed_tab
+
+set_displayed_tab : Tab -> Type -> Type
+set_displayed_tab tab ui = {ui | displayed_tab = (Just tab)}
+
+reset_displayed_tab : Type -> Type
+reset_displayed_tab ui = {ui | displayed_tab = Nothing}
+
+to_string : Tab -> String
+to_string tab =
+ case tab of
+ StatusTab -> "Status"
+ CharactersTab -> "Characters"
+ SettingsTab -> "Settings"
+ TimelineTab -> "Timeline"
+
+get_all_tabs : (List Tab)
+get_all_tabs =
+ [StatusTab, CharactersTab, SettingsTab, TimelineTab]
+
+-- Navigator -------------------------------------------------------------------
+try_getting_displayed_nav : Type -> (Maybe Struct.Navigator.Type)
+try_getting_displayed_nav ui = ui.displayed_nav
+
+set_displayed_nav : Struct.Navigator.Type -> Type -> Type
+set_displayed_nav nav ui = {ui | displayed_nav = (Just nav)}
+
+reset_displayed_nav : Type -> Type
+reset_displayed_nav ui = {ui | displayed_nav = Nothing}
+
+-- ManualControls --------------------------------------------------------------
+has_manual_controls_enabled : Type -> Bool
+has_manual_controls_enabled ui = ui.show_manual_controls
+
+toggle_manual_controls : Type -> Type
+toggle_manual_controls ui =
+ if (ui.show_manual_controls)
+ then
+ {ui | show_manual_controls = False}
+ else
+ {ui | show_manual_controls = True}
+
+set_enable_manual_controls : Bool -> Type -> Type
+set_enable_manual_controls val ui = {ui | show_manual_controls = val}
+
+-- Previous Action -------------------------------------------------------------
+has_focus : Type -> Bool
+has_focus ui = True
+
+set_previous_action : (Maybe Action) -> Type -> Type
+set_previous_action act ui = {ui | previous_action = act}
+
+get_previous_action : Type -> (Maybe Action)
+get_previous_action ui = ui.previous_action