From a06f947c39058b953e00ce43711d3ab2a93293f9 Mon Sep 17 00:00:00 2001 From: fanyx Date: Mon, 4 Jan 2021 19:56:49 +0100 Subject: [PATCH] first steps to change overlay and savegames --- lib/yath_ex/data/savegame.ex | 15 +++++++++++++++ lib/yath_ex/update.ex | 17 +++++++++++++++++ lib/yath_ex/views/menu.ex | 8 ++++++++ 3 files changed, 40 insertions(+) create mode 100644 lib/yath_ex/data/savegame.ex create mode 100644 lib/yath_ex/update.ex create mode 100644 lib/yath_ex/views/menu.ex diff --git a/lib/yath_ex/data/savegame.ex b/lib/yath_ex/data/savegame.ex new file mode 100644 index 0000000..dcf407c --- /dev/null +++ b/lib/yath_ex/data/savegame.ex @@ -0,0 +1,15 @@ +defmodule YathEx.Data.Savegame do + def list_saves do + Path.wildcard("savegame/*.sav") + |> Enum.map(fn save -> + String.replace(save,"savegame\/","") + end) + end + + def mk_save_dir do + if not File.exists?("savegame") do + File.mkdir("savegame") + end + end + +end diff --git a/lib/yath_ex/update.ex b/lib/yath_ex/update.ex new file mode 100644 index 0000000..695b400 --- /dev/null +++ b/lib/yath_ex/update.ex @@ -0,0 +1,17 @@ +defmodule YathEx.Update do + + alias YathEx.Data.Savegame + + def change_view(model, :savegame) do + data = Savegame.list_saves() + %{model | data: data} + end + + def change_view(model, view_id) do + + end + + def set_overlay(model, id) do + %{model | overlay: id} + end +end diff --git a/lib/yath_ex/views/menu.ex b/lib/yath_ex/views/menu.ex new file mode 100644 index 0000000..378fa23 --- /dev/null +++ b/lib/yath_ex/views/menu.ex @@ -0,0 +1,8 @@ +defmodule YathEx.Views.Menu do + + import Ratatouille.View + + def render do + bar() + end +end