Skip to content

Commit

Permalink
Force mood change if there's only one box. Fixes #28.
Browse files Browse the repository at this point in the history
  • Loading branch information
valrus committed Jan 15, 2016
1 parent e484ec6 commit 4136048
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/static/js/DialogBox.elm
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,16 @@ view address chara model =


updateSrc : Maybe String -> Maybe String -> Bool -> Maybe String
updateSrc old new expecting =
if ((old == Nothing) || (new == Nothing) || expecting) then
updateSrc old new wantToSet =
if ((old == Nothing) || wantToSet) then
new
else
old


type Action
= NoOp
| SetImage (Maybe String)
| SetImage (Maybe String) Bool
| SetText (Maybe String)
| ExpectImage Bool

Expand All @@ -208,10 +208,10 @@ update action model =
NoOp ->
model

SetImage src ->
SetImage src force ->
{ model
| imgSrc =
updateSrc model.imgSrc src model.expectingImage
updateSrc model.imgSrc src (model.expectingImage || force)
, expectingImage = False
}

Expand Down
9 changes: 6 additions & 3 deletions src/static/js/DialogBoxes.elm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ convertViewMessage boxNum boxAction =
DialogBox.NoOp ->
NoOp

DialogBox.SetImage s ->
DialogBox.SetImage s force ->
case s of
Nothing ->
NoOp
Expand Down Expand Up @@ -212,7 +212,7 @@ update action model =
( { model
| boxes =
model.boxes
|> updateBoxes (DialogBox.SetImage Nothing)
|> updateBoxes (DialogBox.SetImage Nothing True)
|> resetTexts
, character = Just chara
}
Expand All @@ -221,7 +221,10 @@ update action model =

SetImages src ->
( { model
| boxes = updateBoxes (DialogBox.SetImage (Just src)) model.boxes
| boxes =
updateBoxes
(DialogBox.SetImage (Just src) (count model == 1))
model.boxes
}
, False
)
Expand Down
11 changes: 6 additions & 5 deletions src/static/js/elm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12361,14 +12361,14 @@ Elm.DialogBox.make = function (_elm) {
var _op = {};
var ExpectImage = function (a) { return {ctor: "ExpectImage",_0: a};};
var SetText = function (a) { return {ctor: "SetText",_0: a};};
var SetImage = function (a) { return {ctor: "SetImage",_0: a};};
var SetImage = F2(function (a,b) { return {ctor: "SetImage",_0: a,_1: b};});
var NoOp = {ctor: "NoOp"};
var updateSrc = F3(function (old,$new,expecting) { return _U.eq(old,$Maybe.Nothing) || (_U.eq($new,$Maybe.Nothing) || expecting) ? $new : old;});
var updateSrc = F3(function (old,$new,wantToSet) { return _U.eq(old,$Maybe.Nothing) || wantToSet ? $new : old;});
var update = F2(function (action,model) {
var _p0 = action;
switch (_p0.ctor)
{case "NoOp": return model;
case "SetImage": return _U.update(model,{imgSrc: A3(updateSrc,model.imgSrc,_p0._0,model.expectingImage),expectingImage: false});
case "SetImage": return _U.update(model,{imgSrc: A3(updateSrc,model.imgSrc,_p0._0,model.expectingImage || _p0._1),expectingImage: false});
case "SetText": return _U.update(model,{text: _p0._0});
default: return _U.update(model,{expectingImage: _p0._0});}
});
Expand Down Expand Up @@ -12572,10 +12572,11 @@ Elm.DialogBoxes.make = function (_elm) {
{case "NoOp": return {ctor: "_Tuple2",_0: model,_1: false};
case "SetCharacter": return {ctor: "_Tuple2"
,_0: _U.update(model,
{boxes: resetTexts(A2(updateBoxes,$DialogBox.SetImage($Maybe.Nothing),model.boxes)),character: $Maybe.Just(_p9._0)})
{boxes: resetTexts(A2(updateBoxes,A2($DialogBox.SetImage,$Maybe.Nothing,true),model.boxes))
,character: $Maybe.Just(_p9._0)})
,_1: false};
case "SetImages": return {ctor: "_Tuple2"
,_0: _U.update(model,{boxes: A2(updateBoxes,$DialogBox.SetImage($Maybe.Just(_p9._0)),model.boxes)})
,_0: _U.update(model,{boxes: A2(updateBoxes,A2($DialogBox.SetImage,$Maybe.Just(_p9._0),_U.eq(count(model),1)),model.boxes)})
,_1: false};
case "UpdateText": var _p10 = A3(updateText,_p9._0,_p9._1,getTexts(model));
var focusBoxNum = _p10._0;
Expand Down
4 changes: 2 additions & 2 deletions src/static/js/elm.min.js

Large diffs are not rendered by default.

0 comments on commit 4136048

Please sign in to comment.