Ticket #2141: uses_of_Engine.Console_Write.patch
File uses_of_Engine.Console_Write.patch, 9.0 KB (added by , 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..46680c7 100644
11 11 function removeItem (objectName, pos) 12 12 { 13 13 if (Engine.GetGUIObjectByName (objectName) == null) 14 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "removeItem()", object: objectName }));14 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "removeItem()", object: objectName })); 15 15 16 16 var list = Engine.GetGUIObjectByName (objectName).list; 17 17 var selected = Engine.GetGUIObjectByName (objectName).selected; … … function removeItem (objectName, pos) 41 41 function addItem (objectName, pos, value) 42 42 { 43 43 if (Engine.GetGUIObjectByName (objectName) == null) 44 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "addItem()", object: objectName }));44 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "addItem()", object: objectName })); 45 45 46 46 var list = Engine.GetGUIObjectByName (objectName).list; 47 47 var selected = Engine.GetGUIObjectByName (objectName).selected; … … function addItem (objectName, pos, value) 66 66 function pushItem (objectName, value) 67 67 { 68 68 if (Engine.GetGUIObjectByName (objectName) == null) 69 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "pushItem()", object: objectName }));69 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "pushItem()", object: objectName })); 70 70 71 71 var list = Engine.GetGUIObjectByName (objectName).list; 72 72 list.push (value); … … function pushItem (objectName, value) 81 81 function popItem (objectName) 82 82 { 83 83 if (Engine.GetGUIObjectByName (objectName) == null) 84 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "popItem()", object: objectName }));84 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "popItem()", object: objectName })); 85 85 86 86 var selected = Engine.GetGUIObjectByName (objectName).selected; 87 87 removeItem(objectName, getNumItems(objectName)-1); … … function popItem (objectName) 98 98 function getNumItems (objectName) 99 99 { 100 100 if (Engine.GetGUIObjectByName (objectName) == null) 101 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getNumItems()", object: objectName }));101 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getNumItems()", object: objectName })); 102 102 103 103 var list = Engine.GetGUIObjectByName(objectName).list; 104 104 return list.length; … … function getNumItems (objectName) 110 110 function getItemValue (objectName, pos) 111 111 { 112 112 if (Engine.GetGUIObjectByName (objectName) == null) 113 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getItemValue()", object: objectName }));113 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getItemValue()", object: objectName })); 114 114 115 115 var list = Engine.GetGUIObjectByName(objectName).list; 116 116 return list[pos]; … … function getItemValue (objectName, pos) 122 122 function getCurrItemValue (objectName) 123 123 { 124 124 if (Engine.GetGUIObjectByName (objectName) == null) 125 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getCurrItemValue()", object: objectName }));125 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "getCurrItemValue()", object: objectName })); 126 126 127 127 if (Engine.GetGUIObjectByName(objectName).selected == -1) 128 128 return ""; … … function setCurrItemValue (objectName, string) 138 138 { 139 139 if (Engine.GetGUIObjectByName(objectName) == null) 140 140 { 141 Engine.Console_Write(sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "setCurrItemValue()", object: objectName }));141 error (sprintf(translate("%(functionName)s: %(object)s not found."), { functionName: "setCurrItemValue()", object: objectName })); 142 142 return -1; 143 143 } 144 144 … … function setCurrItemValue (objectName, string) 158 158 } 159 159 160 160 // 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(translate("Requested string '%(string)s' not found in %(object)s's list."), { string: string, object: objectName })); 162 162 return -2; 163 163 } 164 164 -
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
4 4 */ 5 5 6 6 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 // or52 // 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 86 7 // ==================================================================== 87 8 88 9 function fadeOut (soundHandle, fadeDuration) … … function crossFade (outHandle, inHandle, fadeDuration) 123 44 124 45 return true; 125 46 } 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 crash142 // // (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/session.js
diff --git binaries/data/mods/public/gui/session/session.js binaries/data/mods/public/gui/session/session.js index 489ecd2..ee2ca3a 100644
function playRandomAmbient(type) 888 888 break; 889 889 890 890 default: 891 Engine.Console_Write(sprintf(translate("Unrecognized ambient type: %(ambientType)s"), { ambientType: type }));891 error(sprintf(translate("Unrecognized ambient type: %(ambientType)s"), { ambientType: type })); 892 892 break; 893 893 } 894 894 }