Ticket #2141: uses_of_Engine.Console_Write.2.patch

File uses_of_Engine.Console_Write.2.patch, 10.8 KB (added by Adi, 10 years ago)
  • binaries/data/mods/public/gui/common/functions_utility_list.js

    diff --git binaries/data/mods/public/gui/common/functions_utility_list.js binaries/data/mods/public/gui/common/functions_utility_list.js
    index c453a7e..878d606 100644
     
    1111function removeItem (objectName, pos)
    1212{
    1313    if (Engine.GetGUIObjectByName (objectName) == null)
    14         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "removeItem()", object: objectName }));
     14        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "removeItem()", object: objectName }));
    1515
    1616    var list = Engine.GetGUIObjectByName (objectName).list;
    1717    var selected = Engine.GetGUIObjectByName (objectName).selected;
    function removeItem (objectName, pos)  
    4141function addItem (objectName, pos, value)
    4242{
    4343    if (Engine.GetGUIObjectByName (objectName) == null)
    44         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "addItem()", object: objectName }));
     44        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "addItem()", object: objectName }));
    4545
    4646    var list = Engine.GetGUIObjectByName (objectName).list;
    4747    var selected = Engine.GetGUIObjectByName (objectName).selected;
    function addItem (objectName, pos, value)  
    6666function pushItem (objectName, value)
    6767{
    6868    if (Engine.GetGUIObjectByName (objectName) == null)
    69         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "pushItem()", object: objectName }));
     69        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "pushItem()", object: objectName }));
    7070
    7171    var list = Engine.GetGUIObjectByName (objectName).list;
    7272    list.push (value);
    function pushItem (objectName, value)  
    8181function popItem (objectName)
    8282{
    8383    if (Engine.GetGUIObjectByName (objectName) == null)
    84         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "popItem()", object: objectName }));
     84        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "popItem()", object: objectName }));
    8585
    8686    var selected = Engine.GetGUIObjectByName (objectName).selected;
    8787    removeItem(objectName, getNumItems(objectName)-1);
    function popItem (objectName)  
    9898function getNumItems (objectName)
    9999{
    100100    if (Engine.GetGUIObjectByName (objectName) == null)
    101         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getNumItems()", object: objectName }));
     101        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "getNumItems()", object: objectName }));
    102102
    103103    var list = Engine.GetGUIObjectByName(objectName).list;
    104104    return list.length;
    function getNumItems (objectName)  
    110110function getItemValue (objectName, pos)
    111111{
    112112    if (Engine.GetGUIObjectByName (objectName) == null)
    113         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getItemValue()", object: objectName }));
     113        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "getItemValue()", object: objectName }));
    114114
    115115    var list = Engine.GetGUIObjectByName(objectName).list;
    116116    return list[pos];
    function getItemValue (objectName, pos)  
    122122function getCurrItemValue (objectName)
    123123{
    124124    if (Engine.GetGUIObjectByName (objectName) == null)
    125         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getCurrItemValue()", object: objectName }));
     125        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "getCurrItemValue()", object: objectName }));
    126126
    127127    if (Engine.GetGUIObjectByName(objectName).selected == -1)
    128128        return "";
    function setCurrItemValue (objectName, string)  
    138138{
    139139    if (Engine.GetGUIObjectByName(objectName) == null)
    140140    {
    141         Engine.Console_Write (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "setCurrItemValue()", object: objectName }));
     141        error (sprintf("%(functionName)s: %(object)s not found.", { functionName: "setCurrItemValue()", object: objectName }));
    142142        return -1;
    143143    }
    144144
    function setCurrItemValue (objectName, string)  
    158158    }
    159159
    160160    // Return -2 if failed to find value in list.
    161     Engine.Console_Write (sprintf(translate("Requested string '%(string)s' not found in %(object)s's list."), { string: string, object: objectName }));
     161    error (sprintf("Requested string '%(string)s' not found in %(object)s's list.", { string: string, object: objectName }));
    162162    return -2;
    163163}
    164164
  • binaries/data/mods/public/gui/common/functions_utility_music.js

    diff --git binaries/data/mods/public/gui/common/functions_utility_music.js binaries/data/mods/public/gui/common/functions_utility_music.js
    index 681cdf9..63ff896 100644
     
    44*/
    55
    66
    7 
    8 
    9 // ====================================================================
    10 
    11 // Quick run-down of the basic audio commands:
    12 
    13 // Save the specified audio file to handle "s".
    14 // s = new Sound( "audio/music/menu_track.ogg" );
    15 
    16 // Play the sound stored at handle "s" one time (it'll be automatically freed when the playback ends):
    17 // s.play();
    18 
    19 // Play the sound stored at handle "s" continuously:
    20 // s.loop();
    21 
    22 // Close "s" and free it from memory (use in conjunction with loop()):
    23 // s.free();
    24 
    25 // Adjust the gain (volume) of a sound (floating point range between 0 (silent) and 1 (max volume)).
    26 // s.setGain(value);
    27 
    28 // ====================================================================
    29 
    30 function newRandomSound(soundType, soundSubType, soundPrePath)
    31 {
    32     // Return a random audio file by category, to be assigned to a handle.
    33     var randomSoundPath;
    34 
    35     switch (soundType)
    36     {
    37         case "music":
    38             randomSoundPath = "audio/music/"
    39         break;
    40         case "ambient":
    41             randomSoundPath = "audio/ambient/" + soundPrePath + "/";
    42         break;
    43         case "effect":
    44             randomSoundPath = soundPrePath + "/";
    45         break;
    46         default:
    47         break;
    48     }
    49 
    50     // Get names of sounds (attack, command, select, hit, pain).
    51     // or
    52     // Get names of "peace", "menu" (theme) and "battle" tracks.
    53     var soundArray = Engine.BuildDirEntList(randomSoundPath, "*" + soundSubType + "*", false);
    54     if (soundArray.length == 0)
    55     {
    56         Engine.Console_Write (sprintf("Failed to find sounds matching '*%(subtype)s*'", { soundSubType: subtype }));
    57         return undefined;
    58     }
    59     // Get a random number within the sound's range.
    60     var randomSound = getRandom (0, soundArray.length-1);
    61     // Set name of track.
    62     var randomFileName = soundArray[randomSound];
    63 
    64     // Build path to random audio file.
    65     randomSoundPath = randomFileName;
    66 
    67     //Engine.Console_Write("Playing " + randomSoundPath + " ...");
    68 
    69     switch (soundType)
    70     {
    71         case "music":
    72             return new MusicSound(randomSoundPath);
    73         break;
    74         case "ambient":
    75             return new AmbientSound(randomSoundPath);
    76         break;
    77         case "effect":
    78             Engine.Console_Write(sprintf("am loading effect '*%(path)s*'", { path: randomSoundPath }));
    79         break;
    80         default:
    81         break;
    82     }
    83     return new Sound(randomSoundPath);
    84 }
    85 
    867// ====================================================================
    878
    889function fadeOut (soundHandle, fadeDuration)
    function crossFade (outHandle, inHandle, fadeDuration)  
    12344
    12445    return true;
    12546}
    126 
    127 // ====================================================================
    128 
    129 
    130 //const AMBIENT_SOUND = "audio/ambient/dayscape/day_temperate_gen_03.ogg";
    131 
    132 
    133 //const AMBIENT_TEMPERATE = "temperate";
    134 //var currentAmbient;
    135 
    136 //function playRandomAmbient(type)
    137 //{
    138 //  switch (type)
    139 //  {
    140 //      case AMBIENT_TEMPERATE:
    141 //          // Seem to need the underscore at the end of "temperate" to avoid crash
    142 //          // (Might be caused by trying to randomly load day_temperate.xml)
    143 //          currentAmbient = newRandomSound("ambient", "temperate_", "dayscape");
    144 //          if (currentAmbient)
    145 //          {
    146 //              currentAmbient.loop();
    147 //              currentAmbient.setGain(0.8);
    148 //          }
    149 //          break;
    150 //
    151 //      default:
    152 //          Engine.Console_Write("Unrecognized ambient type: " + type);
    153 //          break;
    154 //  }
    155 //}
    156 //
    157 //function stopAmbient()
    158 //{
    159 //  if (currentAmbient)
    160 //  {
    161 //      currentAmbient.fade(-1, 0.0, 5.0);
    162 //      currentAmbient = null;
    163 //  }
    164 //}
    165 
    166 //const BUTTON_SOUND = "audio/interface/ui/ui_button_longclick.ogg";
    167 //function playButtonSound()
    168 //{
    169 //    var buttonSound = new Sound(BUTTON_SOUND);
    170 //    buttonSound.play();
    171 //}
  • binaries/data/mods/public/gui/session/messages.js

    diff --git binaries/data/mods/public/gui/session/messages.js binaries/data/mods/public/gui/session/messages.js
    index 678bd6e..3849a69 100644
    function addChatMessage(msg, playerAssignments)  
    497497        {
    498498            if (msg.context !== "")
    499499            {
    500                 Engine.Console_Write(sprintf(translate("(%(context)s) * %(user)s %(message)s"), {
    501                     context: msg.context,
    502                     user: username,
    503                     message: message
    504                 }));
    505500                formatted = sprintf(translate("(%(context)s) * %(user)s %(message)s"), {
    506501                    context: msg.context,
    507502                    user: "[color=\"" + playerColor + "\"]" + username + "[/color]",
    function addChatMessage(msg, playerAssignments)  
    510505            }
    511506            else
    512507            {
    513                 Engine.Console_Write(sprintf(translate("* %(user)s %(message)s"), {
    514                     user: username,
    515                     message: message
    516                 }));
    517508                formatted = sprintf(translate("* %(user)s %(message)s"), {
    518509                    user: "[color=\"" + playerColor + "\"]" + username + "[/color]",
    519510                    message: message
    function addChatMessage(msg, playerAssignments)  
    526517            var formattedUserTag = sprintf(translate("<%(user)s>"), { user: "[color=\"" + playerColor + "\"]" + username + "[/color]" })
    527518            if (msg.context !== "")
    528519            {
    529                 Engine.Console_Write(sprintf(translate("(%(context)s) %(userTag)s %(message)s"), {
    530                     context: msg.context,
    531                     userTag: userTag,
    532                     message: message
    533                 }));
    534520                formatted = sprintf(translate("(%(context)s) %(userTag)s %(message)s"), {
    535521                    context: msg.context,
    536522                    userTag: formattedUserTag,
    function addChatMessage(msg, playerAssignments)  
    539525            }
    540526            else
    541527            {
    542                 Engine.Console_Write(sprintf(translate("%(userTag)s %(message)s"), { userTag: userTag, message: message}));
    543528                formatted = sprintf(translate("%(userTag)s %(message)s"), { userTag: formattedUserTag, message: message});
    544529            }
    545530        }
  • binaries/data/mods/public/gui/session/session.js

    diff --git binaries/data/mods/public/gui/session/session.js binaries/data/mods/public/gui/session/session.js
    index 489ecd2..5b3f77c 100644
    function playRandomAmbient(type)  
    888888            break;
    889889
    890890        default:
    891             Engine.Console_Write(sprintf(translate("Unrecognized ambient type: %(ambientType)s"), { ambientType: type }));
     891            error(sprintf("Unrecognized ambient type: %(ambientType)s", { ambientType: type }));
    892892            break;
    893893    }
    894894}