Saving much better!

This commit is contained in:
Bryce Covert
2015-11-04 17:07:26 -08:00
parent 3326629189
commit 6586faf583
12 changed files with 78 additions and 71 deletions

View File

@@ -342,8 +342,7 @@
:ego "What's this?")
(actions/give entities :kiss)
(actions/do-dialogue entities :ego "A kiss for an inventory item?"
:ego "Sounds like the game designer was running out of good ideas.")
(utils/snapshot-state @entities :after-cat))
:ego "Sounds like the game designer was running out of good ideas."))
(actions/talk entities :ego "I guess I'm too far away.")))
:default (actions/get-script entities (actions/talk entities :ego "Kitty seems disinterested in it."))})
cat-stand)

View File

@@ -243,7 +243,7 @@
:fairy-godfather "Choose the broom or shovel, and cast it into the pit of fate."
:ego "But..."
:fairy-godfather "No buts.")
(utils/snapshot-state @entities :beginning)
(utils/save-chapter @entities :chapter-1)
(actions/update-state entities #(assoc % :seen-intro? true :time :day)))
(defn swing [entities]
@@ -422,7 +422,7 @@
:ego "If I only really could be a knight."
:ego "Then I'd be able to win Georgia McGorgeous' heart.")
(actions/in-love entities)
(utils/snapshot-state @entities :after-dream))
(utils/save-chapter @entities :chapter-2))
(do (actions/walk-to entities :ego [148 76] :face :right)
(actions/do-dialogue entities
:fairy-godfather "What are you doing?" :ego "Erm... Nothing."))))

View File

@@ -80,8 +80,7 @@
:warriors "Congratulations, young master. Thou art worthy in might."
:warriors "Take thy servant's medal of strength.")
(actions/give entities :medal)
(actions/glad entities)
(utils/snapshot-state @entities :after-strength))
(actions/glad entities))
(do
(play-battle entities :lose)
(actions/do-dialogue entities

View File

@@ -585,7 +585,7 @@
(actions/remove-entity entities :trophy)
(actions/glad entities)
(actions/talk entities :ego "Thanks!")
(utils/snapshot-state @entities :after-wisdom))
)
(actions/do-dialogue entities :ego "What about this?" :game-player "No, that's not the solution. Keep looking."))
(brian-get-to-work entities))
:trophy (actions/get-script entities

View File

@@ -198,7 +198,7 @@
:ego "But what now?"
:ego "I have till sunrise before Bloodclot comes and destroys the town."
:ego "Maybe Gandarf can help me!")
(utils/snapshot-state @entities :after-jail))
(utils/save-chapter @entities :chapter-4))
(do
(actions/do-dialogue entities :ego "Yes! I made it!"
:guard "Hmm?"

View File

@@ -210,7 +210,7 @@
:wizard "If this is truely your quest, then I will help you. "
:ego "So you're my friend now, Gandarf?"
:wizard "No.")
(utils/save @entities))}]})
(utils/save @entities :autosave "Autosave"))}]})
(defn wizard-dialogue [entities]
(if (get-in @entities [:state :has-met-gandarf?])
@@ -623,7 +623,7 @@
(if (get-in @entities [:state :convinced-wizard?])
(do (actions/talk entities :wizard (str "Oh, hello there boy."))
(utils/save @entities))
(utils/save @entities :autosave "Autosave"))
(wizard-dialogue entities)))))
:cursor :right}

View File

@@ -279,7 +279,7 @@
(bloodclot-disappear entities)
(common/go-to-jail entities 5.0)
(actions/do-dialogue entities :ego "Hey!" :ego "What's going on? I was just about to teach Bloodclot a lesson!")
(utils/snapshot-state @entities :in-jail))))
(utils/save-chapter @entities :chapter-3))))
:magic-slingshot (actions/get-script entities
(actions/do-dialogue entities
:ego "Hey Bloodclot!"

View File

@@ -819,7 +819,7 @@ void main ()
(defn get-state [selected-save]
(if selected-save
(utils/load-snapshot selected-save)
(assoc (:state selected-save) :active? true)
{:object nil
:active? true
:last-room :dream
@@ -1245,6 +1245,10 @@ void main ()
:on-show-inventory (fn [screen [entities]]
(click-inventory screen entities))
:on-save (fn [screen [entities]]
(when-not (get-in entities [:actions :script-running?])
(utils/save entities (str (java.util.UUID/randomUUID)) (str "Save " (rand-int 20)))))
:on-menu (fn [{:keys [viewport] :as screen} [entities]]
(when-not (or (get-in entities [:tweens :fade-out])
(get-in entities [:tweens :fade-in]))
@@ -1373,5 +1377,8 @@ void main ()
(utils/intersects? (:close entities) [x y])
(screen! scene :on-menu)
(utils/intersects? (:save entities) [x y])
(screen! scene :on-save)
:else
nil)))))

View File

@@ -101,7 +101,7 @@
flipped))
(defn quest-label []
(if (:seen-intro? (utils/load-snapshot :autosave))
(if (seq (utils/snapshot-list))
"Continue quest"
"Begin quest"))
@@ -210,19 +210,20 @@
(.setUncheckLast true))
[cell-w cell-h] [218 161]
make-cell (fn [image] [image :width cell-w :pad 4 4 4 4 :height cell-h])
make-save-screenshot (fn [[save-name save-screenshot]]
make-save-screenshot (fn [{:keys [screenshot name id state] :as save}]
(let [btn (doto (assoc (image-button (skin "ui/ui.json"))
:save save-name)
(image-button! :set-size cell-w cell-h)
(image-button! :add (doto (Group. )
(.setSize (- cell-w 16) (- cell-h 16) )
(.setOrigin (/ (- cell-w 16) 2) (/ (- cell-h 16) 2))
(.addActor (:object (doto (image (texture save-screenshot))
(image! :set-size (- cell-w 16) (- cell-h 16)))))
(.addActor (:object (make-label (str " " (subs save-name 0 (min (.length save-name) 10))))))
))
save-object)]
:save save
:name name)
(image-button! :set-size cell-w cell-h)
(image-button! :add (doto (Group. )
(.setSize (- cell-w 16) (- cell-h 16) )
(.setOrigin (/ (- cell-w 16) 2) (/ (- cell-h 16) 2))
(.addActor (:object (doto (image (texture screenshot))
(image! :set-size (- cell-w 16) (- cell-h 16)))))
(.addActor (:object (make-label (str " " (subs name 0 (min (.length name) 10))))))
))
save-object)]
(.add group (:object btn))
(ActorEntity. (:object btn))))
save-screenshots (map make-save-screenshot (:saves-list entities))
@@ -381,14 +382,14 @@
(= :continue-or-start actor-key)
(start-playing screen entities (if (= "Begin quest" (quest-label))
nil
:autosave))
(first (utils/snapshot-list))))
(= :continue actor-key)
(start-playing screen entities (saves/name->save (:selected-save entities)))
(start-playing screen entities (:selected-save entities))
(:save e)
(do
(label! (-> entities :save-menu :save-label) :set-text (:save e))
(label! (-> entities :save-menu :save-label) :set-text (:name (:save e)))
(text-button! (-> entities :save-menu :continue-button) :set-disabled false)
(assoc entities :selected-save (:save e)))