Skip to content

Commit

Permalink
Merge branch 'feature/16/dragon-shout-pronunciation'
Browse files Browse the repository at this point in the history
  • Loading branch information
Odie committed Oct 14, 2018
2 parents bc68ee5 + 127d511 commit d4fed7c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/Common/Shared/GlobalFunc.as
Expand Up @@ -227,4 +227,7 @@ class Shared.GlobalFunc
return trimStr;
}

static function StringReplaceAll(str:String, search:String, replace:String):String {
return str.split(search).join(replace);
}
}
44 changes: 37 additions & 7 deletions src/ItemMenus/ItemCard.as
Expand Up @@ -7,6 +7,7 @@ import Components.DeltaMeter;
import Shared.GlobalFunc;

import skyui.defines.Inventory;
import skyui.util.Debug;


class ItemCard extends MovieClip
Expand Down Expand Up @@ -68,6 +69,8 @@ class ItemCard extends MovieClip
var _bEditNameMode: Boolean;
var bFadedIn: Boolean;

var LastShoutObj: Object;


function ItemCard()
{
Expand All @@ -84,6 +87,19 @@ class ItemCard extends MovieClip
_bEditNameMode = false;
}

function shoutWordPronunciation(word: String): String
{
word = GlobalFunc.StringReplaceAll(word, "1", "aa");
word = GlobalFunc.StringReplaceAll(word, "2", "ei");
word = GlobalFunc.StringReplaceAll(word, "3", "ii");
word = GlobalFunc.StringReplaceAll(word, "4", "ah");
word = GlobalFunc.StringReplaceAll(word, "6", "ur");
word = GlobalFunc.StringReplaceAll(word, "7", "ir");
word = GlobalFunc.StringReplaceAll(word, "8", "oo");
word = GlobalFunc.StringReplaceAll(word, "9", "ey");
return word.charAt(0).toUpperCase() + word.slice(1);
}

function get bEditNameMode(): Boolean
{
return _bEditNameMode;
Expand Down Expand Up @@ -311,22 +327,36 @@ class ItemCard extends MovieClip
var strDragonWord: String = aUpdateObj["dragonWord" + i] == undefined ? "" : aUpdateObj["dragonWord" + i];
var strWord: String = aUpdateObj["word" + i] == undefined ? "" : aUpdateObj["word" + i];
var bWordKnown: Boolean = aUpdateObj["unlocked" + i] == true;
this["ShoutTextInstance" + i].DragonShoutLabelInstance.ShoutWordsLabel.textAutoSize = "shrink";
this["ShoutTextInstance" + i].ShoutLabelInstance.ShoutWordsLabelTranslation.textAutoSize = "shrink";
this["ShoutTextInstance" + i].DragonShoutLabelInstance.ShoutWordsLabel.SetText(strDragonWord.toUpperCase());
this["ShoutTextInstance" + i].ShoutLabelInstance.ShoutWordsLabelTranslation.SetText(strWord);
var textInstance = this["ShoutTextInstance" + i];

textInstance.ShoutPronunciation.ShoutWordsLabel.textAutoSize = "shrink";
textInstance.DragonShoutLabelInstance.ShoutWordsLabel.textAutoSize = "shrink";
textInstance.ShoutLabelInstance.ShoutWordsLabelTranslation.textAutoSize = "shrink";

textInstance.ShoutPronunciation.ShoutWordsLabel.SetText(shoutWordPronunciation(strDragonWord));
textInstance.DragonShoutLabelInstance.ShoutWordsLabel.SetText(strDragonWord.toUpperCase());
textInstance.ShoutLabelInstance.ShoutWordsLabelTranslation.SetText(strWord);
if (bWordKnown && i == iLastWord && LastUpdateObj.soulSpent == true) {
this["ShoutTextInstance" + i].gotoAndPlay("Learn");
} else if (bWordKnown) {
this["ShoutTextInstance" + i].gotoAndStop("Known");
this["ShoutTextInstance" + i].gotoAndStop("Known");
// The word is known.
// If we're displaying the same shout we were displaying "last" time,
// (likely because we just learned a new word)
// do not interrup the 'learn' or previous 'translate' animation that is
// already in progress.
if(LastShoutObj["name"] != aUpdateObj["name"]) {
this["ShoutTextInstance" + i].gotoAndPlay("Translate");
}
} else {
this["ShoutTextInstance" + i].gotoAndStop("Unlocked");
this["ShoutTextInstance" + i].gotoAndStop("Unlocked");
}
}
ShoutEffectsLabel.SetText(aUpdateObj.effects, true);
ShoutCostValue.SetText(aUpdateObj.spellCost.toString());

// Hang on to this shout data
// We need this to properly animate the pronunciation label
LastShoutObj = aUpdateObj;
break;

case Inventory.ICT_ACTIVE_EFFECT:
Expand Down
Binary file modified src/ItemMenus/itemcard.fla
Binary file not shown.

0 comments on commit d4fed7c

Please sign in to comment.