systemobj.cpp 107 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500
  1. #include <precomp.h>
  2. #include <bfc/wasabi_std.h>
  3. #include <bfc/wasabi_std_wnd.h>
  4. #include <api/script/script.h>
  5. #include <api/script/scriptmgr.h>
  6. #include <api/script/scriptobj.h>
  7. #include <api/script/scriptguid.h>
  8. #include <api/script/objects/systemobj.h>
  9. #include <api/service/svcs/svc_action.h>
  10. #include <api/util/selectfile.h>
  11. #include <api/script/vcpu.h> // for getAtom, CUT
  12. #ifdef WASABI_COMPILE_WNDMGR
  13. #include <api/wnd/wndclass/wndholder.h>
  14. #include <api/wndmgr/skinembed.h>
  15. #endif
  16. #include <api/script/objects/timer.h>
  17. #include <time.h>
  18. #include <api.h>
  19. #ifdef WASABI_COMPILE_SKIN
  20. #include <api/skin/skinparse.h>
  21. #include <api/skin/skin.h>
  22. #endif
  23. #include <math.h>
  24. #include <shlobj.h>
  25. #include <bfc/string/url.h>
  26. #include <bfc/parse/pathparse.h>
  27. #include <bfc/tlist.h>
  28. #ifdef WASABI_COMPILE_WNDMGR
  29. #include <api/util/varmgr.h>
  30. #endif
  31. #include <bfc/nsguid.h>
  32. #include <api/script/objecttable.h>
  33. #include <api/skin/groupmgr.h>
  34. #ifdef WA3COMPATIBILITY
  35. #include <api/skin/widgets/mb/xuibrowser.h>
  36. #include <api/skin/widgets/mb/mainminibrowser.h>
  37. #include <api/util/dde.h>
  38. #include <api/wac/main.h>//CUT!!
  39. #endif
  40. #ifdef WASABI_COMPILE_MEDIACORE
  41. #include <api/service/svcs/svc_player.h>
  42. #include <api/core/buttons.h>
  43. #include <api/core/api_core.h>
  44. #include <api/core/corehandle.h> // safe to include even if core isn't there
  45. #endif
  46. #ifdef WASABI_COMPILE_CONFIG
  47. #include <api/config/items/attrbool.h>
  48. #endif
  49. #include <api/locales/xlatstr.h>
  50. #include "../Agave/Language/api_language.h"
  51. #include <api/syscb/callbacks/consolecb.h>
  52. #include "../nu/AutoChar.h"
  53. #include "../nu/AutoUrl.h"
  54. #include "../nu/AutoWide.h"
  55. #ifdef _WIN32
  56. #include <shlwapi.h>
  57. extern HINSTANCE hInstance;
  58. #endif
  59. #ifdef GEN_FF
  60. #include "../../../../Plugins/General/gen_ff/wa2frontend.h"
  61. #endif
  62. SystemScriptObjectController _systemController;
  63. SystemScriptObjectController *systemController = &_systemController;
  64. #define MAKI_RUNTIME_VERSION 2
  65. // -- Functions table -------------------------------------
  66. function_descriptor_struct SystemScriptObjectController::exportedFunction[] =
  67. {
  68. {L"getRuntimeVersion", 0, (void*)SystemObject::vcpu_getVersion},
  69. {L"onScriptLoaded", 0, (void*)SystemObject::vcpu_onScriptLoaded},
  70. {L"onScriptUnloading", 0, (void*)SystemObject::vcpu_onScriptUnloading},
  71. {L"onQuit", 0, (void*)SystemObject::vcpu_onQuit},
  72. {L"onKeyDown", 1, (void*)SystemObject::vcpu_onKeyDown},
  73. {L"onKeyUp", 1, (void*)SystemObject::vcpu_onKeyUp},
  74. {L"onAccelerator", 3, (void*)SystemObject::vcpu_onAccelerator},
  75. {L"getMousePosX", 0, (void*)SystemObject::vcpu_getMousePosX},
  76. {L"getMousePosY", 0, (void*)SystemObject::vcpu_getMousePosY},
  77. {L"isMinimized", 0, (void*)SystemObject::vcpu_isMinimized},
  78. {L"restoreApplication", 0, (void*)SystemObject::vcpu_restoreApplication},
  79. {L"activateApplication", 0, (void*)SystemObject::vcpu_activateApplication},
  80. {L"minimizeApplication", 0, (void*)SystemObject::vcpu_minimizeApplication},
  81. {L"isDesktopAlphaAvailable", 0, (void*)SystemObject::vcpu_isDesktopAlphaAvailable},
  82. {L"isTransparencyAvailable", 0, (void*)SystemObject::vcpu_isTransparencyAvailable},
  83. //-----
  84. {L"integerToString", 1, (void*)SystemObject::vcpu_integerToString},
  85. {L"stringToInteger", 1, (void*)SystemObject::vcpu_stringToInteger},
  86. {L"floatToString", 2, (void*)SystemObject::vcpu_floatToString},
  87. {L"stringToFloat", 1, (void*)SystemObject::vcpu_stringToFloat},
  88. {L"integerToTime", 1, (void*)SystemObject::vcpu_integerToTime},
  89. {L"integerToLongTime", 1, (void*)SystemObject::vcpu_integerToLongTime},
  90. {L"dateToTime", 1, (void*)SystemObject::vcpu_dateToTime},
  91. {L"dateToLongTime", 1, (void*)SystemObject::vcpu_dateToLongTime},
  92. {L"formatDate", 1, (void*)SystemObject::vcpu_formatDate},
  93. {L"formatLongDate", 1, (void*)SystemObject::vcpu_formatLongDate},
  94. {L"getDateYear", 1, (void*)SystemObject::vcpu_getDateYear},
  95. {L"getDateMonth", 1, (void*)SystemObject::vcpu_getDateMonth},
  96. {L"getDateDay", 1, (void*)SystemObject::vcpu_getDateDay},
  97. {L"getDateDow", 1, (void*)SystemObject::vcpu_getDateDow},
  98. {L"getDateDoy", 1, (void*)SystemObject::vcpu_getDateDoy},
  99. {L"getDateHour", 1, (void*)SystemObject::vcpu_getDateHour},
  100. {L"getDateMin", 1, (void*)SystemObject::vcpu_getDateMin},
  101. {L"getDateSec", 1, (void*)SystemObject::vcpu_getDateSec},
  102. {L"getDateDst", 1, (void*)SystemObject::vcpu_getDateDst},
  103. {L"getDate", 0, (void*)SystemObject::vcpu_getDate},
  104. {L"StrMid", 3, (void*)SystemObject::vcpu_strmid},
  105. {L"StrLeft", 2, (void*)SystemObject::vcpu_strleft},
  106. {L"StrRight", 2, (void*)SystemObject::vcpu_strright},
  107. {L"StrSearch", 2, (void*)SystemObject::vcpu_strsearch},
  108. {L"StrLen", 1, (void*)SystemObject::vcpu_strlen},
  109. {L"StrUpper", 1, (void*)SystemObject::vcpu_strupper},
  110. {L"StrLower", 1, (void*)SystemObject::vcpu_strlower},
  111. {L"UrlEncode", 1, (void*)SystemObject::vcpu_urlencode},
  112. {L"UrlDecode", 1, (void*)SystemObject::vcpu_urldecode},
  113. {L"RemovePath", 1, (void*)SystemObject::vcpu_removepath},
  114. {L"GetPath", 1, (void*)SystemObject::vcpu_getpath},
  115. {L"GetExtension", 1, (void*)SystemObject::vcpu_getextension},
  116. {L"getToken", 3, (void*)SystemObject::vcpu_gettoken},
  117. //-----
  118. {L"sin", 1, (void*)SystemObject::vcpu_sin},
  119. {L"cos", 1, (void*)SystemObject::vcpu_cos},
  120. {L"tan", 1, (void*)SystemObject::vcpu_tan},
  121. {L"asin", 1, (void*)SystemObject::vcpu_asin},
  122. {L"acos", 1, (void*)SystemObject::vcpu_acos},
  123. {L"atan", 1, (void*)SystemObject::vcpu_atan},
  124. {L"atan2", 2, (void*)SystemObject::vcpu_atan2},
  125. {L"pow", 2, (void*)SystemObject::vcpu_pow},
  126. {L"sqr", 1, (void*)SystemObject::vcpu_sqr},
  127. {L"sqrt", 1, (void*)SystemObject::vcpu_sqrt},
  128. {L"random", 1, (void*)SystemObject::vcpu_random},
  129. {L"integer", 1, (void*)SystemObject::vcpu_integer},
  130. {L"frac", 1, (void*)SystemObject::vcpu_frac},
  131. {L"ln", 1, (void*)SystemObject::vcpu_log},
  132. {L"log10", 1, (void*)SystemObject::vcpu_log10},
  133. //-----
  134. {L"getParam", 0, (void*)SystemObject::vcpu_getParam},
  135. {L"getViewportWidth", 0, (void*)SystemObject::vcpu_getViewportWidth},
  136. {L"getViewportHeight", 0, (void*)SystemObject::vcpu_getViewportHeight},
  137. {L"getViewportLeft", 0, (void*)SystemObject::vcpu_getViewportLeft},
  138. {L"getViewportTop", 0, (void*)SystemObject::vcpu_getViewportTop},
  139. {L"getViewportWidthFromPoint", 2, (void*)SystemObject::vcpu_getViewportWidthFP},
  140. {L"getViewportHeightFromPoint",2, (void*)SystemObject::vcpu_getViewportHeightFP},
  141. {L"getViewportLeftFromPoint", 2, (void*)SystemObject::vcpu_getViewportLeftFP},
  142. {L"getViewportTopFromPoint", 2, (void*)SystemObject::vcpu_getViewportTopFP},
  143. {L"getViewportWidthFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportWidthGO},
  144. {L"getViewportHeightFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportHeightGO},
  145. {L"getViewportLeftFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportLeftGO},
  146. {L"getViewportTopFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportTopGO},
  147. {L"onViewPortChanged", 2, (void*)SystemObject::vcpu_onViewPortChanged},
  148. {L"debugString", 2, (void*)SystemObject::vcpu_debugString},
  149. {L"isObjectValid", 1, (void*)SystemObject::vcpu_isObjectValid},
  150. {L"getTimeOfDay", 0, (void*)SystemObject::vcpu_getTimeOfDay},
  151. {L"navigateUrl", 1, (void*)SystemObject::vcpu_navigateUrl},
  152. {L"navigateUrlBrowser", 1, (void*)SystemObject::vcpu_navigateUrlBrowser},
  153. {L"isKeyDown", 1, (void*)SystemObject::vcpu_isKeyDown},
  154. {L"setClipboardText", 1, (void*)SystemObject::vcpu_setClipboard},
  155. {L"Chr", 1, (void*)SystemObject::vcpu_chr},
  156. {L"triggerAction", 3, (void*)SystemObject::vcpu_triggerAction},
  157. {L"messageBox", 4, (void*)SystemObject::vcpu_messageBox},
  158. {L"setAtom", 2, (void*)SystemObject::vcpu_setAtom},
  159. {L"getAtom", 1, (void*)SystemObject::vcpu_getAtom},
  160. #ifdef WASABI_COMPILE_MAKIDEBUG
  161. {L"invokeDebugger", 0, (void*)SystemObject::vcpu_invokeDebugger},
  162. #endif
  163. #ifdef WASABI_COMPILE_SKIN
  164. {L"newGroup", 1, (void*)SystemObject::vcpu_newGroup},
  165. {L"onSetXuiParam", 2, (void*)SystemObject::vcpu_onSetXuiParam},
  166. {L"getScriptGroup", 0, (void*)SystemObject::vcpu_getScriptGroup},
  167. {L"getSkinName", 0, (void*)SystemObject::vcpu_getSkinName},
  168. {L"newGroupAsLayout", 1, (void*)SystemObject::vcpu_newGroupAsLayout},
  169. {L"getNumContainers", 0, (void*)SystemObject::vcpu_getNumContainers},
  170. {L"enumContainer", 1, (void*)SystemObject::vcpu_enumContainer},
  171. {L"onCreateLayout", 1, (void*)SystemObject::vcpu_onCreateLayout},
  172. {L"onShowLayout", 1, (void*)SystemObject::vcpu_onShowLayout},
  173. {L"onHideLayout", 1, (void*)SystemObject::vcpu_onHideLayout},
  174. {L"switchSkin", 1, (void*)SystemObject::vcpu_switchSkin},
  175. {L"isLoadingSkin", 0, (void*)SystemObject::vcpu_isLoadingSkin},
  176. {L"lockUI", 0, (void*)SystemObject::vcpu_lockUI},
  177. {L"unlockUI", 0, (void*)SystemObject::vcpu_unlockUI},
  178. #endif
  179. #if defined(WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  180. {
  181. L"getContainer", 1, (void*)SystemObject::vcpu_getContainer
  182. },
  183. {L"newDynamicContainer", 1, (void*)SystemObject::vcpu_newDynamicContainer},
  184. {L"onGetCancelComponent", 2, (void*)SystemObject::vcpu_onGetCancelComponent},
  185. {L"onLookForComponent", 1, (void*)SystemObject::vcpu_onLookForComponent},
  186. {L"isAppActive", 0, (void*)SystemObject::vcpu_isAppActive},
  187. {L"showWindow", 3, (void*)SystemObject::vcpu_showWindow},
  188. {L"hideWindow", 1, (void*)SystemObject::vcpu_hideWindow},
  189. {L"hideNamedWindow", 1, (void*)SystemObject::vcpu_hideNamedWindow},
  190. {L"isNamedWindowVisible", 1, (void*)SystemObject::vcpu_isNamedWindowVisible},
  191. {L"getCurAppLeft", 0, (void*)SystemObject::vcpu_getCurAppLeft},
  192. {L"getCurAppTop", 0, (void*)SystemObject::vcpu_getCurAppTop},
  193. {L"getCurAppWidth", 0, (void*)SystemObject::vcpu_getCurAppWidth},
  194. {L"getCurAppHeight", 0, (void*)SystemObject::vcpu_getCurAppHeight},
  195. #endif
  196. #if defined (WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  197. {
  198. L"setPrivateString", 3, (void*)SystemObject::vcpu_setPrivateString
  199. },
  200. {L"setPrivateInt", 3, (void*)SystemObject::vcpu_setPrivateInt},
  201. {L"getPrivateString", 3, (void*)SystemObject::vcpu_getPrivateString},
  202. {L"getPrivateInt", 3, (void*)SystemObject::vcpu_getPrivateInt},
  203. {L"setPublicString", 2, (void*)SystemObject::vcpu_setPublicString},
  204. {L"setPublicInt", 2, (void*)SystemObject::vcpu_setPublicInt},
  205. {L"getPublicString", 2, (void*)SystemObject::vcpu_getPublicString},
  206. {L"getPublicInt", 2, (void*)SystemObject::vcpu_getPublicInt},
  207. #endif
  208. #if defined (WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  209. {
  210. L"getPlayItemString", 0, (void*)SystemObject::vcpu_getPlayItemString
  211. },
  212. {L"getPlayItemLength", 0, (void*)SystemObject::vcpu_getPlayItemLength},
  213. {L"getPlayItemMetadataString", 1, (void*)SystemObject::vcpu_getPlayItemMetadataString},
  214. {L"getMetadataString", 2, (void*)SystemObject::vcpu_getMetadataString},
  215. {L"getPlayItemDisplayTitle", 0, (void*)SystemObject::vcpu_getPlayItemDisplayTitle},
  216. {L"getExtFamily", 1, (void*)SystemObject::vcpu_getExtFamily},
  217. {L"getDecoderName", 1, (void*)SystemObject::vcpu_getDecoderName},
  218. {L"playFile", 1, (void*)SystemObject::vcpu_playFile},
  219. {L"enqueueFile", 1, (void*)SystemObject::vcpu_enqueueFile},
  220. {L"clearPlaylist", 0, (void*)SystemObject::vcpu_clearPlaylist},
  221. {L"onStop", 0, (void*)SystemObject::vcpu_onStop},
  222. {L"onPlay", 0, (void*)SystemObject::vcpu_onPlay},
  223. {L"onPause", 0, (void*)SystemObject::vcpu_onPause},
  224. {L"onResume", 0, (void*)SystemObject::vcpu_onResume},
  225. {L"onTitleChange", 1, (void*)SystemObject::vcpu_onTitleChange},
  226. {L"onTitle2Change", 1, (void*)SystemObject::vcpu_onTitle2Change},
  227. {L"onUrlChange", 1, (void*)SystemObject::vcpu_onUrlChange},
  228. {L"onInfoChange", 1, (void*)SystemObject::vcpu_onInfoChange},
  229. {L"onStatusMsg", 1, (void*)SystemObject::vcpu_onStatusMsg},
  230. {L"getLeftVuMeter", 0, (void*)SystemObject::vcpu_getLeftVuMeter},
  231. {L"getRightVuMeter", 0, (void*)SystemObject::vcpu_getRightVuMeter},
  232. {L"getVisBand", 2, (void*)SystemObject::vcpu_getVisBand},
  233. {L"getVolume", 0, (void*)SystemObject::vcpu_getVolume},
  234. {L"setVolume", 1, (void*)SystemObject::vcpu_setVolume},
  235. {L"play", 0, (void*)SystemObject::vcpu_play},
  236. {L"stop", 0, (void*)SystemObject::vcpu_stop},
  237. {L"pause", 0, (void*)SystemObject::vcpu_pause},
  238. {L"next", 0, (void*)SystemObject::vcpu_next},
  239. {L"previous", 0, (void*)SystemObject::vcpu_previous},
  240. {L"eject", 0, (void*)SystemObject::vcpu_eject},
  241. {L"seekTo", 1, (void*)SystemObject::vcpu_seekTo},
  242. {L"getPosition", 0, (void*)SystemObject::vcpu_getPosition},
  243. {L"setEqBand", 2, (void*)SystemObject::vcpu_setEqBand},
  244. {L"setEqPreAmp", 1, (void*)SystemObject::vcpu_setEqPreAmp},
  245. {L"setEq", 1, (void*)SystemObject::vcpu_setEq},
  246. {L"getEqBand", 1, (void*)SystemObject::vcpu_getEqBand},
  247. {L"getEqPreAmp", 0, (void*)SystemObject::vcpu_getEqPreAmp},
  248. {L"getEq", 0, (void*)SystemObject::vcpu_getEq},
  249. {L"onEqBandChanged", 2, (void*)SystemObject::vcpu_onEqBandChanged},
  250. {L"onEqFreqChanged", 1, (void*)SystemObject::vcpu_onEqFreqChanged},
  251. {L"onEqPreAmpChanged", 1, (void*)SystemObject::vcpu_onEqPreAmpChanged},
  252. {L"onEqChanged", 1, (void*)SystemObject::vcpu_onEqChanged},
  253. {L"onVolumeChanged", 1, (void*)SystemObject::vcpu_onVolumeChanged},
  254. {L"onSeek", 1, (void*)SystemObject::vcpu_onSeeked},
  255. {L"getStatus", 0, (void*)SystemObject::vcpu_getStatus},
  256. {L"getStatus", 0, (void*)SystemObject::vcpu_getStatus},
  257. {L"getSongInfoText", 0, (void*)SystemObject::vcpu_getSongInfoText},
  258. {L"getSongInfoTextTranslated", 0, (void*)SystemObject::vcpu_getSongInfoTextTranslated},
  259. {L"hasVideoSupport", 0, (void*)SystemObject::vcpu_hasVideoSupport},
  260. {L"isVideo", 0, (void*)SystemObject::vcpu_isVideo},
  261. {L"isVideoFullscreen", 0, (void*)SystemObject::vcpu_isVideoFullscreen},
  262. {L"setVideoFullscreen", 1, (void*)SystemObject::vcpu_setVideoFullscreen},
  263. {L"getIdealVideoWidth", 0, (void*)SystemObject::vcpu_getIdealVideoWidth},
  264. {L"getIdealVideoHeight", 0, (void*)SystemObject::vcpu_getIdealVideoHeight},
  265. {L"getPlaylistIndex", 0, (void*)SystemObject::vcpu_getPlaylistIndex},
  266. {L"onShowNotification", 0, (void*)SystemObject::vcpu_onShowNotification},
  267. {L"getPlaylistLength", 0, (void*)SystemObject::vcpu_getPlaylistLength},
  268. {L"getCurrentTrackRating", 0, (void *)SystemObject::vcpu_getRating},
  269. {L"setCurrentTrackRating", 1, (void *)SystemObject::vcpu_setRating},
  270. #endif
  271. #if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  272. {
  273. L"getWac", 1, (void*)SystemObject::vcpu_getWac
  274. },
  275. #endif
  276. #if defined(WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  277. {
  278. L"ddesend", 3, (void*)SystemObject::vcpu_ddeSend
  279. },
  280. {L"setMenuTransparency", 1, (void*)SystemObject::vcpu_setMenuTransparency},
  281. {L"popMainBrowser", 0, (void*)SystemObject::vcpu_popMb},
  282. {L"getMainBrowser", 0, (void*)SystemObject::vcpu_getMainMB},
  283. {L"windowMenu", 0, (void*)SystemObject::vcpu_windowMenu},
  284. {L"systemMenu", 0, (void*)SystemObject::vcpu_systemMenu},
  285. #endif
  286. #if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  287. {
  288. L"selectFile", 3, (void*)SystemObject::vcpu_selectFile
  289. },
  290. #endif
  291. {L"selectFolder", 3, (void*)SystemObject::vcpu_selectFolder},
  292. {L"onOpenURL", 1, (void*)SystemObject::vcpu_onOpenURL},
  293. {L"getMonitorLeft", 0, (void*)SystemObject::vcpu_getMonitorLeftGO},
  294. {L"getMonitorTop", 0, (void*)SystemObject::vcpu_getMonitorTopGO},
  295. {L"getMonitorLeftFromPoint", 2, (void*)SystemObject::vcpu_getMonitorLeftFP},
  296. {L"getMonitorTopFromPoint", 2, (void*)SystemObject::vcpu_getMonitorTopFP},
  297. {L"getMonitorLeftFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorLeftGO},
  298. {L"getMonitorTopFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorTopGO},
  299. {L"getMonitorWidth", 0, (void*)SystemObject::vcpu_getMonitorWidth},
  300. {L"getMonitorHeight", 0, (void*)SystemObject::vcpu_getMonitorHeight},
  301. {L"getMonitorWidthFromPoint", 2, (void*)SystemObject::vcpu_getMonitorWidthFP},
  302. {L"getMonitorHeightFromPoint",2, (void*)SystemObject::vcpu_getMonitorHeightFP},
  303. {L"getMonitorWidthFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorWidthGO},
  304. {L"getMonitorHeightFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorHeightGO},
  305. {L"downloadURL", 3, (void*)SystemObject::vcpu_downloadURL},
  306. {L"downloadMedia", 4, (void*)SystemObject::vcpu_downloadMedia},
  307. {L"onDownloadFinished", 3, (void*)SystemObject::vcpu_onDownloadFinished},
  308. {L"getDownloadPath", 0, (void*)SystemObject::vcpu_getDownloadPath},
  309. {L"setDownloadPath", 1, (void*)SystemObject::vcpu_setDownloadPath},
  310. {L"getAlbumArt", 1, (void*)SystemObject::vcpu_getAlbumArt},
  311. {L"isProVersion", 0, (void*)SystemObject::vcpu_isWinampPro}, // ugh, i hate putting this here but ohh well
  312. {L"enumEmbedGUID", 1, (void*)SystemObject::vcpu_enumEmbedGUID}, // ugh, i hate putting this here but ohh well
  313. {L"getWinampVersion",0, (void*)SystemObject::vcpu_getWinampVersion},
  314. {L"getBuildNumber",0, (void*)SystemObject::vcpu_getBuildNumber},
  315. {L"getFileSize",1, (void*)SystemObject::vcpu_getFileSize},
  316. {L"getString", 2, (void*)SystemObject::vcpu_getString},
  317. {L"translate", 1, (void*)SystemObject::vcpu_translate},
  318. {L"getLanguageId", 0, (void*)SystemObject::vcpu_getLanguageId}
  319. };
  320. // --------------------------------------------------------
  321. const wchar_t *SystemScriptObjectController::getClassName()
  322. {
  323. return L"SystemObject";
  324. }
  325. const wchar_t *SystemScriptObjectController::getAncestorClassName()
  326. {
  327. return L"Object";
  328. }
  329. ScriptObject *SystemScriptObjectController::instantiate()
  330. {
  331. return NULL;
  332. }
  333. void SystemScriptObjectController::destroy(ScriptObject *o)
  334. {
  335. ASSERTALWAYS("don't delete systemobject!");
  336. }
  337. void *SystemScriptObjectController::encapsulate(ScriptObject *o)
  338. {
  339. return NULL;
  340. }
  341. void SystemScriptObjectController::deencapsulate(void *o)
  342. {
  343. }
  344. int SystemScriptObjectController::getNumFunctions()
  345. {
  346. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  347. }
  348. const function_descriptor_struct *SystemScriptObjectController::getExportedFunctions()
  349. {
  350. return exportedFunction;
  351. }
  352. GUID SystemScriptObjectController::getClassGuid()
  353. {
  354. return systemObjectGuid;
  355. }
  356. int SystemScriptObjectController::getReferenceable()
  357. {
  358. return 0;
  359. }
  360. int SystemScriptObjectController::getInstantiable()
  361. {
  362. return 0;
  363. }
  364. #ifndef _NOSTUDIO
  365. SystemObject::SystemObject()
  366. {
  367. getScriptObject()->vcpu_setInterface( systemObjectGuid, ( void * )static_cast<SystemObject *>( this ) );
  368. getScriptObject()->vcpu_setClassName( L"System" );
  369. getScriptObject()->vcpu_setController( systemController );
  370. loaded = 0;
  371. started_up = 0;
  372. scriptVCPUId = -1;
  373. isoldformat = 0;
  374. parentGroup = NULL;
  375. #ifdef WASABI_COMPILE_SKIN
  376. skinpartid = WASABI_API_PALETTE->getSkinPartIterator();
  377. #else
  378. skinpartid = -1;
  379. #endif
  380. SOM::registerSystemObject( this );
  381. #ifdef WASABI_COMPILE_MEDIACORE
  382. WASABI_API_MEDIACORE->core_addCallback( 0, this );
  383. #endif
  384. WASABI_API_SYSCB->syscb_registerCallback( this );
  385. }
  386. SystemObject::~SystemObject()
  387. {
  388. SOM::unregisterSystemObject( this );
  389. #ifdef WASABI_COMPILE_MEDIACORE
  390. WASABI_API_MEDIACORE->core_delCallback( 0, this );
  391. #endif
  392. WASABI_API_SYSCB->syscb_deregisterCallback( this );
  393. }
  394. void SystemObject::setScriptId( int id )
  395. {
  396. scriptVCPUId = id;
  397. }
  398. int SystemObject::getScriptId()
  399. {
  400. return scriptVCPUId;
  401. }
  402. void SystemObject::setParam( const wchar_t *p )
  403. {
  404. #ifdef WASABI_COMPILE_WNDMGR
  405. StringW *s = PublicVarManager::translate_nocontext( p );
  406. if ( s )
  407. param.swap( s );
  408. else
  409. param = p;
  410. delete s;
  411. #else
  412. param = p;
  413. #endif
  414. }
  415. void SystemObject::setParentGroup( Group *g )
  416. {
  417. parentGroup = g;
  418. }
  419. Group *SystemObject::getParentGroup()
  420. {
  421. return parentGroup;
  422. }
  423. const wchar_t *SystemObject::getParam()
  424. {
  425. return param;
  426. }
  427. void SystemObject::onLoad()
  428. {
  429. loaded = 1;
  430. vcpu_onScriptLoaded( SCRIPT_CALL, getScriptObject() );
  431. started_up = 1;
  432. }
  433. void SystemObject::onUnload()
  434. {
  435. if ( loaded && started_up )
  436. vcpu_onScriptUnloading( SCRIPT_CALL, getScriptObject() );
  437. // that was the script's last chance to delete its stuff, now we need to garbageCollect whatever is left
  438. garbageCollect();
  439. }
  440. #ifdef WASABI_COMPILE_WNDMGR
  441. WindowHolder *SystemObject::getSuitableWindowHolderByGuid( GUID g )
  442. {
  443. wchar_t guidstr[ 256 ] = { 0 };
  444. nsGUID::toCharW( g, guidstr );
  445. scriptVar v = vcpu_onLookForComponent( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( guidstr ) );
  446. if ( v.type == SCRIPT_OBJECT )
  447. {
  448. ScriptObject *ret = GET_SCRIPT_OBJECT( v );
  449. if ( ret )
  450. {
  451. WindowHolder *co = static_cast<WindowHolder *>( ret->vcpu_getInterface( windowHolderGuid ) );
  452. return co;
  453. }
  454. }
  455. return NULL;
  456. }
  457. int SystemObject::onGetCancelComponent( GUID g, int i )
  458. {
  459. wchar_t guidstr[ 256 ] = { 0 };
  460. nsGUID::toCharW( g, guidstr );
  461. scriptVar v = vcpu_onGetCancelComponent( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( guidstr ), MAKE_SCRIPT_BOOLEAN( i ) );
  462. if ( v.type != SCRIPT_VOID )
  463. return GET_SCRIPT_INT( v );
  464. return 0;
  465. }
  466. void SystemObject::onViewPortChanged( int width, int height )
  467. {
  468. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- )
  469. vcpu_onViewPortChanged( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_INT( width ), MAKE_SCRIPT_INT( height ) );
  470. }
  471. int SystemObject::onShowNotification()
  472. {
  473. WASABI_API_MAKI->vcpu_resetComplete();
  474. #if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  475. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- )
  476. {
  477. scriptVar v = vcpu_onShowNotification( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject() );
  478. if ( v.type != SCRIPT_VOID )
  479. return GET_SCRIPT_INT( v );
  480. }
  481. #endif
  482. return 0;
  483. }
  484. void SystemObject::onCreateLayout( Layout *l )
  485. {
  486. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- )
  487. vcpu_onCreateLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) );
  488. }
  489. void SystemObject::onShowLayout( Layout *l )
  490. {
  491. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- )
  492. vcpu_onShowLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) );
  493. }
  494. void SystemObject::onHideLayout( Layout *l )
  495. {
  496. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- )
  497. vcpu_onHideLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) );
  498. }
  499. int SystemObject::getCurAppRect( RECT *r )
  500. {
  501. ASSERT( r );
  502. #ifdef WIN32
  503. HWND w = GetForegroundWindow();
  504. if ( !IsWindowVisible( w ) ) return 0;
  505. GetWindowRect( w, r );
  506. #else
  507. DebugString( "portme SystemObject::getCurAppRect\n" );
  508. #endif
  509. return 1;
  510. }
  511. void SystemObject::onQuit()
  512. {
  513. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- )
  514. vcpu_onQuit( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject() );
  515. }
  516. #endif // wndmgr
  517. static bool FilterBrowserUrl( const wchar_t *url )
  518. {
  519. const wchar_t filterNowPlaying[] = L"http://client.winamp.com/nowplaying";
  520. size_t urlLength, filterLength;
  521. if ( NULL == url )
  522. return false;
  523. urlLength = wcslen( url );
  524. filterLength = sizeof( filterNowPlaying ) / sizeof( filterNowPlaying[ 0 ] ) - 1;
  525. if ( urlLength >= filterLength &&
  526. 0 == _wcsnicmp( url, filterNowPlaying, filterLength ) )
  527. {
  528. return true;
  529. }
  530. return false;
  531. }
  532. void SystemObject::browsercb_onOpenURL( wchar_t *url, bool *override )
  533. {
  534. if ( !*override && false == FilterBrowserUrl( url ) ) // ignore if someone else already overrode
  535. {
  536. scriptVar v = vcpu_onOpenURL( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( url ) );
  537. if ( v.type == SCRIPT_INT )
  538. {
  539. if ( v.data.idata == 1 )
  540. *override = true;
  541. }
  542. }
  543. }
  544. scriptVar SystemObject::vcpu_onOpenURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url )
  545. {
  546. SCRIPT_FUNCTION_INIT;
  547. #ifdef WASABI_COMPILE_MEDIACORE
  548. PROCESS_HOOKS1( o, systemController, url );
  549. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  550. SCRIPT_EXEC_EVENT1( o, url );
  551. #else
  552. RETURN_SCRIPT_VOID;
  553. #endif
  554. }
  555. void SystemObject::onKeyDown( const wchar_t *s )
  556. {
  557. WASABI_API_MAKI->vcpu_resetComplete();
  558. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- )
  559. vcpu_onKeyDown( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( s ) );
  560. }
  561. void SystemObject::onKeyUp( const wchar_t *s )
  562. {
  563. WASABI_API_MAKI->vcpu_resetComplete();
  564. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- )
  565. vcpu_onKeyUp( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( s ) );
  566. }
  567. int SystemObject::onAccelerator( const wchar_t *action, const wchar_t *section, const wchar_t *key )
  568. {
  569. int r = 0;
  570. WASABI_API_MAKI->vcpu_resetComplete();
  571. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- )
  572. {
  573. scriptVar v = vcpu_onAccelerator( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( action ), MAKE_SCRIPT_STRING( section ), MAKE_SCRIPT_STRING( key ) );
  574. if ( SOM::isNumeric( &v ) )
  575. r |= GET_SCRIPT_INT( v );
  576. }
  577. return r;
  578. }
  579. void SystemObject::onDownloadFinished( const wchar_t *url, boolean success, const wchar_t *filename )
  580. {
  581. for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- )
  582. vcpu_onDownloadFinished( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( url ), MAKE_SCRIPT_BOOLEAN( success ), MAKE_SCRIPT_STRING( filename ) );
  583. }
  584. TList < int > *SystemObject::getTypesList()
  585. {
  586. return &typeslist;
  587. }
  588. void SystemObject::setIsOldFormat( int is )
  589. {
  590. isoldformat = is;
  591. }
  592. int SystemObject::isOldFormat()
  593. {
  594. return isoldformat;
  595. }
  596. #endif
  597. #ifdef WASABI_COMPILE_WND
  598. int SystemObject::isAppActive()
  599. {
  600. #ifdef WIN32
  601. HWND w = GetForegroundWindow();
  602. wchar_t classname[ 256 ] = L"";
  603. GetClassNameW( w, classname, 256 );
  604. return ( w == WASABI_API_WND->main_getRootWnd()->gethWnd() || !wcscmp( classname, BASEWNDCLASSNAME ) );
  605. #else
  606. DebugString( "portme SystemObject::isAppActive\n" );
  607. return 1;
  608. #endif
  609. }
  610. #endif
  611. void SystemObject::setSkinPartId( int _skinpartid )
  612. {
  613. skinpartid = _skinpartid;
  614. }
  615. int SystemObject::getSkinPartId()
  616. {
  617. return skinpartid;
  618. }
  619. void SystemObject::addInstantiatedObject( ScriptObject *obj )
  620. {
  621. ASSERT( !instantiated.haveItem( obj ) );
  622. instantiated.addItem( obj );
  623. }
  624. void SystemObject::removeInstantiatedObject( ScriptObject *obj )
  625. {
  626. int n = instantiated.searchItem( obj );
  627. if ( n < 0 ) return; //ASSERT(n >= 0);
  628. instantiated.removeByPos( n );
  629. }
  630. void SystemObject::garbageCollect()
  631. {
  632. foreach( instantiated )
  633. ObjectTable::destroy( instantiated.getfor() );
  634. endfor
  635. instantiated.removeAll();
  636. }
  637. int SystemObject::isObjectValid( ScriptObject *o )
  638. {
  639. static ScriptObject *cached = NULL;
  640. static int cachedn = -1;
  641. if ( o == cached && scriptobjects.enumItem( cachedn ) == o ) return 1;
  642. int is = scriptobjects.searchItem( o );
  643. if ( is >= 0 )
  644. {
  645. cached = o;
  646. cachedn = is;
  647. }
  648. return ( is > -1 );
  649. }
  650. void SystemObject::addScriptObject( ScriptObject *o )
  651. {
  652. ASSERT( !scriptobjects.haveItem( o ) );
  653. scriptobjects.addItem( o );
  654. }
  655. void SystemObject::removeScriptObject( ScriptObject *o )
  656. {
  657. int pos = scriptobjects.searchItem( o );
  658. if ( pos < 0 ) return;
  659. scriptobjects.removeByPos( pos );
  660. }
  661. #ifdef WASABI_COMPILE_SKIN
  662. void SystemObject::onSetXuiParam( const wchar_t *param, const wchar_t *value )
  663. {
  664. vcpu_onSetXuiParam( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( param ), MAKE_SCRIPT_STRING( value ) );
  665. }
  666. #endif
  667. void SystemObject::navigateUrl( const wchar_t *url )
  668. {
  669. #ifdef WA3COMPATIBILITY
  670. if ( MainMiniBrowser::getScriptObject() )
  671. {
  672. MainMiniBrowser::navigateUrl( url );
  673. MainMiniBrowser::popMb();
  674. }
  675. else // no minibrowser container -> launch IE
  676. {
  677. Std::shellExec( url );
  678. }
  679. #else
  680. Wasabi::Std::shellExec( url );
  681. #endif
  682. }
  683. void SystemObject::navigateUrlBrowser( const wchar_t *url )
  684. {
  685. wa2.openUrl( url );
  686. }
  687. scriptVar SystemObject::vcpu_getVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  688. {
  689. SCRIPT_FUNCTION_INIT;
  690. PROCESS_HOOKS0( o, systemController );
  691. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  692. return MAKE_SCRIPT_DOUBLE( MAKI_RUNTIME_VERSION );
  693. }
  694. scriptVar SystemObject::vcpu_onScriptLoaded( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  695. {
  696. SCRIPT_FUNCTION_INIT;
  697. PROCESS_HOOKS0( o, systemController );
  698. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  699. SystemObject *so = static_cast<SystemObject *>( o->vcpu_getInterface( systemObjectGuid ) );
  700. ASSERT( so != NULL );
  701. return WASABI_API_MAKI->maki_triggerEvent( o, DLF_ID, 0, so->scriptVCPUId );
  702. }
  703. scriptVar SystemObject::vcpu_onScriptUnloading( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  704. {
  705. SCRIPT_FUNCTION_INIT;
  706. PROCESS_HOOKS0( o, systemController );
  707. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  708. SystemObject *so = static_cast<SystemObject *>( o->vcpu_getInterface( systemObjectGuid ) );
  709. ASSERT( so != NULL );
  710. return WASABI_API_MAKI->maki_triggerEvent( o, DLF_ID, 0, so->scriptVCPUId );
  711. }
  712. scriptVar SystemObject::vcpu_onQuit( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  713. {
  714. SCRIPT_FUNCTION_INIT;
  715. PROCESS_HOOKS0( o, systemController );
  716. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  717. SCRIPT_EXEC_EVENT0( o );
  718. }
  719. #ifdef WASABI_COMPILE_SKIN
  720. scriptVar SystemObject::vcpu_onSetXuiParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value )
  721. {
  722. SCRIPT_FUNCTION_INIT;
  723. PROCESS_HOOKS2( o, systemController, param, value );
  724. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  725. SCRIPT_EXEC_EVENT2( o, param, value );
  726. }
  727. scriptVar SystemObject::vcpu_getSkinName( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  728. {
  729. SCRIPT_FUNCTION_INIT;
  730. return MAKE_SCRIPT_STRING( WASABI_API_SKIN->getSkinName() );
  731. }
  732. scriptVar SystemObject::vcpu_switchSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar skinname )
  733. {
  734. SCRIPT_FUNCTION_INIT;
  735. #ifdef SWITCH_SKIN
  736. SWITCH_SKIN( GET_SCRIPT_STRING( skinname ) );
  737. #else
  738. WASABI_API_SKIN->skin_switchSkin( GET_SCRIPT_STRING( skinname ) );
  739. #endif
  740. RETURN_SCRIPT_ZERO;
  741. }
  742. scriptVar SystemObject::vcpu_isLoadingSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  743. {
  744. SCRIPT_FUNCTION_INIT;
  745. int l = 0;
  746. #ifdef IS_SKIN_STILL_LOADING
  747. IS_SKIN_STILL_LOADING( l );
  748. #endif
  749. if ( !l ) return MAKE_SCRIPT_INT( Skin::isLoading() );
  750. return MAKE_SCRIPT_INT( l );
  751. }
  752. scriptVar SystemObject::vcpu_lockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  753. {
  754. SCRIPT_FUNCTION_INIT;
  755. WASABI_API_SKIN->skin_setLockUI( 1 );
  756. RETURN_SCRIPT_NULL;
  757. }
  758. scriptVar SystemObject::vcpu_unlockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  759. {
  760. SCRIPT_FUNCTION_INIT;
  761. WASABI_API_SKIN->skin_setLockUI( 0 );
  762. RETURN_SCRIPT_NULL;
  763. }
  764. #endif
  765. scriptVar SystemObject::vcpu_isObjectValid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar o )
  766. {
  767. SCRIPT_FUNCTION_INIT;
  768. return MAKE_SCRIPT_BOOLEAN( SystemObject::isObjectValid( GET_SCRIPT_OBJECT( o ) ) );
  769. }
  770. scriptVar SystemObject::vcpu_getTimeOfDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  771. {
  772. SCRIPT_FUNCTION_INIT;
  773. time_t ts = Wasabi::Std::getTimeStamp();
  774. struct tm *tm_now;
  775. tm_now = localtime( (const time_t *)&ts );
  776. uint32_t tcnow = Wasabi::Std::getTickCount();
  777. static uint32_t lasttc = 0;
  778. int v = tm_now->tm_hour * 3600000 + tm_now->tm_min * 60000 + tm_now->tm_sec * 1000;
  779. // yay milliseconds!
  780. static int lastv = 0;
  781. static int total = 0;
  782. int tv = v;
  783. if ( v == lastv )
  784. {
  785. total += tcnow - lasttc;
  786. v += total;
  787. }
  788. else total = 0;
  789. lasttc = tcnow;
  790. lastv = tv;
  791. return MAKE_SCRIPT_INT( v );
  792. }
  793. scriptVar SystemObject::vcpu_navigateUrl( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url )
  794. {
  795. SCRIPT_FUNCTION_INIT;
  796. SystemObject::navigateUrl( GET_SCRIPT_STRING( url ) );
  797. RETURN_SCRIPT_VOID;
  798. }
  799. scriptVar SystemObject::vcpu_navigateUrlBrowser( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url )
  800. {
  801. SCRIPT_FUNCTION_INIT;
  802. SystemObject::navigateUrlBrowser( GET_SCRIPT_STRING( url ) );
  803. RETURN_SCRIPT_VOID;
  804. }
  805. scriptVar SystemObject::vcpu_isKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar vk_code )
  806. {
  807. SCRIPT_FUNCTION_INIT;
  808. return MAKE_SCRIPT_INT( Std::keyDown( GET_SCRIPT_INT( vk_code ) ) );
  809. }
  810. scriptVar SystemObject::vcpu_setClipboard( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar text )
  811. {
  812. SCRIPT_FUNCTION_INIT;
  813. #ifdef _WIN32
  814. const wchar_t *source = GET_SCRIPT_STRING( text );
  815. DebugStringW( L"%s\n", source );
  816. OpenClipboard( 0 );
  817. EmptyClipboard();
  818. int len = ( wcslen( source ) + 1 );
  819. HGLOBAL clipbuffer = GlobalAlloc( GMEM_DDESHARE, sizeof( wchar_t ) * len );
  820. wchar_t *buffer = (wchar_t *)GlobalLock( clipbuffer );
  821. wcsncpy( buffer, source, len - 1 );
  822. GlobalUnlock( clipbuffer );
  823. SetClipboardData( CF_UNICODETEXT, clipbuffer );
  824. CloseClipboard();
  825. #else
  826. DebugString( "portme SystemObject::vcpu_setClipboard\n" );
  827. #endif
  828. RETURN_SCRIPT_VOID;
  829. }
  830. scriptVar SystemObject::vcpu_chr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n )
  831. {
  832. SCRIPT_FUNCTION_INIT;
  833. WCSCPYN( staticStr, StringPrintfW( L"%c", GET_SCRIPT_INT( n ) ), 4096 );
  834. return MAKE_SCRIPT_STRING( staticStr );
  835. }
  836. scriptVar SystemObject::vcpu_onAccelerator( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar section, scriptVar key )
  837. {
  838. SCRIPT_FUNCTION_INIT;
  839. PROCESS_HOOKS3( o, systemController, action, section, key );
  840. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  841. SCRIPT_EXEC_EVENT3( o, action, section, key );
  842. }
  843. scriptVar SystemObject::vcpu_triggerAction( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guiobj, scriptVar actionstr, scriptVar paramstr )
  844. {
  845. SCRIPT_FUNCTION_INIT;
  846. ASSERT( actionstr.type == SCRIPT_STRING );
  847. ASSERT( paramstr.type == SCRIPT_STRING );
  848. const wchar_t *astr = GET_SCRIPT_STRING( actionstr );
  849. const wchar_t *pstr = GET_SCRIPT_STRING( paramstr );
  850. #ifdef WASABI_COMPILE_WNDMGR
  851. ScriptObject *context = guiobj.data.odata;
  852. if ( context != NULL )
  853. {
  854. GuiObject *go = static_cast<GuiObject *>( context->vcpu_getInterface( guiObjectGuid ) );
  855. if ( go != NULL )
  856. {
  857. ifc_window *wc = go->guiobject_getRootWnd();
  858. if ( wc != NULL )
  859. {
  860. ifc_window *lr = wc->getDesktopParent();
  861. if ( lr != NULL )
  862. {
  863. Layout *lay = static_cast<Layout *>( lr->getInterface( layoutGuid ) );
  864. if ( lay != NULL )
  865. {
  866. int ia = WASABI_API_SKIN->parse( astr, L"internal_action" );
  867. if ( ia == ACTION_NONE )
  868. {
  869. ActionEnum ae( astr );
  870. svc_action *act = ae.getFirst();
  871. if ( act )
  872. {
  873. act->onAction( astr, pstr, 0, 0, NULL, 0, wc );
  874. SvcEnum::release( act );
  875. }
  876. }
  877. else
  878. lay->runAction( ia, pstr );
  879. }
  880. }
  881. }
  882. }
  883. }
  884. else
  885. {
  886. ActionEnum ae( astr );
  887. svc_action *act = ae.getFirst();
  888. if ( act )
  889. {
  890. act->onAction( astr, pstr );
  891. SvcEnum::release( act );
  892. }
  893. }
  894. #endif
  895. RETURN_SCRIPT_VOID;
  896. }
  897. scriptVar SystemObject::vcpu_getParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  898. {
  899. SCRIPT_FUNCTION_INIT;
  900. SystemObject *o = static_cast<SystemObject *>( object->vcpu_getInterface( systemObjectGuid ) );
  901. if ( o ) return MAKE_SCRIPT_STRING( o->getParam() );
  902. return MAKE_SCRIPT_STRING( L"" );
  903. }
  904. #ifdef WASABI_COMPILE_SKIN
  905. scriptVar SystemObject::vcpu_getScriptGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  906. {
  907. SCRIPT_FUNCTION_INIT;
  908. SystemObject *o = static_cast<SystemObject *>( object->vcpu_getInterface( systemObjectGuid ) );
  909. if ( o )
  910. {
  911. Group *g = o->getParentGroup();
  912. return MAKE_SCRIPT_OBJECT( g ? g->getScriptObject() : NULL );
  913. }
  914. return MAKE_SCRIPT_OBJECT( NULL );
  915. }
  916. scriptVar SystemObject::vcpu_newGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname )
  917. {
  918. SCRIPT_FUNCTION_INIT;
  919. GuiObject *g = SkinParser::newDynamicGroup( GET_SCRIPT_STRING( groupname ), GROUP_GROUP );
  920. if ( g != NULL )
  921. {
  922. SystemObject *so = static_cast<SystemObject *>( object->vcpu_getInterface( systemObjectGuid ) );
  923. so->addInstantiatedObject( g->guiobject_getScriptObject() );
  924. }
  925. return MAKE_SCRIPT_OBJECT( g ? g->guiobject_getScriptObject() : NULL );
  926. }
  927. #endif
  928. scriptVar SystemObject::vcpu_getMousePosX( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  929. {
  930. SCRIPT_FUNCTION_INIT;
  931. POINT pt;
  932. Wasabi::Std::getMousePos( &pt );
  933. return MAKE_SCRIPT_INT( pt.x );
  934. }
  935. scriptVar SystemObject::vcpu_getMousePosY( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  936. {
  937. SCRIPT_FUNCTION_INIT;
  938. POINT pt;
  939. Wasabi::Std::getMousePos( &pt );
  940. return MAKE_SCRIPT_INT( pt.y );
  941. }
  942. scriptVar SystemObject::vcpu_minimizeApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  943. {
  944. SCRIPT_FUNCTION_INIT;
  945. #ifdef _WIN32
  946. ShowWindow( WASABI_API_WND->main_getRootWnd()->gethWnd(), SW_MINIMIZE );
  947. #else
  948. #warning port me
  949. #endif
  950. RETURN_SCRIPT_VOID;
  951. }
  952. scriptVar SystemObject::vcpu_activateApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  953. {
  954. SCRIPT_FUNCTION_INIT;
  955. #ifdef _WIN32
  956. SetForegroundWindow( WASABI_API_WND->main_getRootWnd()->gethWnd() );
  957. #else
  958. #warning port me
  959. #endif
  960. RETURN_SCRIPT_VOID;
  961. }
  962. scriptVar SystemObject::vcpu_restoreApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  963. {
  964. SCRIPT_FUNCTION_INIT;
  965. #ifdef _WIN32
  966. ShowWindow( WASABI_API_WND->main_getRootWnd()->gethWnd(), SW_RESTORE );
  967. #else
  968. #warning port me
  969. #endif
  970. RETURN_SCRIPT_VOID;
  971. }
  972. scriptVar SystemObject::vcpu_isDesktopAlphaAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  973. {
  974. SCRIPT_FUNCTION_INIT;
  975. #ifdef WASABI_COMPILE_CONFIG
  976. extern _bool cfg_uioptions_desktopalpha;
  977. return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isDesktopAlphaAvailable() && cfg_uioptions_desktopalpha.getValueAsInt() );
  978. #else
  979. return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isDesktopAlphaAvailable() );
  980. #endif
  981. }
  982. scriptVar SystemObject::vcpu_isTransparencyAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  983. {
  984. SCRIPT_FUNCTION_INIT;
  985. return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isTransparencyAvailable() );
  986. }
  987. scriptVar SystemObject::vcpu_isMinimized( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  988. {
  989. SCRIPT_FUNCTION_INIT;
  990. #ifdef _WIN32
  991. return MAKE_SCRIPT_INT( IsIconic( WASABI_API_WND->main_getRootWnd()->gethWnd() ) );
  992. #else
  993. #warning port me
  994. RETURN_SCRIPT_ZERO;
  995. #endif
  996. }
  997. // extern String System.translate(String str);
  998. scriptVar SystemObject::vcpu_translate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str )
  999. {
  1000. SCRIPT_FUNCTION_INIT;
  1001. WCSCPYN( translateStr, _( GET_SCRIPT_STRING( str ) ), ( sizeof( translateStr ) / sizeof( *translateStr ) ) );
  1002. return MAKE_SCRIPT_STRING( translateStr );
  1003. }
  1004. // extern String System.getString(String table, Int id);
  1005. scriptVar SystemObject::vcpu_getString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar table, scriptVar id )
  1006. {
  1007. SCRIPT_FUNCTION_INIT;
  1008. const wchar_t *xlat = LocalesManager::GetString( GET_SCRIPT_STRING( table ), GET_SCRIPT_INT( id ) );
  1009. if ( xlat )
  1010. return MAKE_SCRIPT_STRING( xlat );
  1011. else
  1012. return MAKE_SCRIPT_STRING( L"" );
  1013. }
  1014. // extern String System.getString(String table, Int id);
  1015. scriptVar SystemObject::vcpu_getLanguageId( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1016. {
  1017. SCRIPT_FUNCTION_INIT;
  1018. const wchar_t *langId = WASABI_API_LNG->GetLanguageIdentifier( LANG_IDENT_STR );
  1019. if ( langId )
  1020. return MAKE_SCRIPT_STRING( langId );
  1021. else
  1022. return MAKE_SCRIPT_STRING( L"" );
  1023. }
  1024. scriptVar SystemObject::vcpu_integerToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar i )
  1025. {
  1026. SCRIPT_FUNCTION_INIT;
  1027. WCSNPRINTF( staticStr, 4096, L"%d", GET_SCRIPT_INT( i ) );
  1028. return MAKE_SCRIPT_STRING( staticStr );
  1029. }
  1030. scriptVar SystemObject::vcpu_stringToInteger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s )
  1031. {
  1032. SCRIPT_FUNCTION_INIT;
  1033. return MAKE_SCRIPT_INT( WTOI( GET_SCRIPT_STRING( s ) ) );
  1034. }
  1035. scriptVar SystemObject::vcpu_floatToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar f, scriptVar digits )
  1036. {
  1037. SCRIPT_FUNCTION_INIT;
  1038. // to whoever made this use StringPrintf, you left out the digits param, GRRRRRR!!
  1039. double v = GET_SCRIPT_DOUBLE( f );
  1040. StringPrintfW tmp( v );
  1041. WCSCPYN( staticStr, tmp, ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1042. wchar_t *p = wcschr( staticStr, '.' );
  1043. if ( p )
  1044. {
  1045. int numdigits = GET_SCRIPT_INT( digits );
  1046. if ( numdigits > 0 )
  1047. {
  1048. int n = numdigits;
  1049. int curnumdigits = staticStr + wcslen( staticStr ) - ( p + 1 );
  1050. n -= curnumdigits;
  1051. if ( n > 0 )
  1052. {
  1053. for ( int i = 0; i < n && i < ( sizeof( staticStr ) / sizeof( *staticStr ) ) - 128; i++ )
  1054. wcscat( staticStr, L"0" );
  1055. }
  1056. else if ( n < 0 )
  1057. {
  1058. *( p + 1 + numdigits ) = 0;
  1059. }
  1060. }
  1061. else
  1062. {
  1063. *p = 0;
  1064. }
  1065. }
  1066. else
  1067. {
  1068. int n = GET_SCRIPT_INT( digits );
  1069. if ( n > 0 )
  1070. {
  1071. wcscat( staticStr, L"." );
  1072. for ( int i = 0; i < n && i < ( sizeof( staticStr ) / sizeof( *staticStr ) ) - 128; i++ )
  1073. wcscat( staticStr, L"0" );
  1074. }
  1075. }
  1076. return MAKE_SCRIPT_STRING( staticStr );
  1077. }
  1078. scriptVar SystemObject::vcpu_stringToFloat( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s )
  1079. {
  1080. SCRIPT_FUNCTION_INIT;
  1081. return MAKE_SCRIPT_FLOAT( (float)WTOF( GET_SCRIPT_STRING( s ) ) );
  1082. }
  1083. scriptVar SystemObject::vcpu_integerToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1084. {
  1085. SCRIPT_FUNCTION_INIT;
  1086. int i = GET_SCRIPT_INT( _i );
  1087. WCSNPRINTF( staticStr, 4096, L"%d:%02d", i / 60000, i % 60000 / 1000 );
  1088. return MAKE_SCRIPT_STRING( staticStr );
  1089. }
  1090. scriptVar SystemObject::vcpu_integerToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1091. {
  1092. SCRIPT_FUNCTION_INIT;
  1093. int i = GET_SCRIPT_INT( _i );
  1094. WCSNPRINTF( staticStr, 4096, L"%d:%02d:%02d", i / 3600000, ( i % 3600000 ) / 60000, i % 60000 / 1000 );
  1095. return MAKE_SCRIPT_STRING( staticStr );
  1096. }
  1097. scriptVar SystemObject::vcpu_dateToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1098. {
  1099. SCRIPT_FUNCTION_INIT;
  1100. //CUT: int i = GET_SCRIPT_INT(_i);
  1101. time_t tt = GET_SCRIPT_INT( _i );
  1102. struct tm *t = localtime( &tt );
  1103. WCSNPRINTF( staticStr, 4096, L"%d:%02d", t->tm_hour, t->tm_min );
  1104. return MAKE_SCRIPT_STRING( staticStr );
  1105. }
  1106. scriptVar SystemObject::vcpu_dateToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1107. {
  1108. SCRIPT_FUNCTION_INIT;
  1109. //CUT: int i = GET_SCRIPT_INT(_i);
  1110. time_t tt = GET_SCRIPT_INT( _i );
  1111. struct tm *t = localtime( &tt );
  1112. WCSNPRINTF( staticStr, 4096, L"%d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec );
  1113. return MAKE_SCRIPT_STRING( staticStr );
  1114. }
  1115. scriptVar SystemObject::vcpu_formatDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1116. {
  1117. SCRIPT_FUNCTION_INIT;
  1118. //CUT: int i = GET_SCRIPT_INT(_i);
  1119. time_t tt = GET_SCRIPT_INT( _i );
  1120. struct tm *t = localtime( &tt );
  1121. wcsftime( staticStr, 4096, L"%c", t );
  1122. return MAKE_SCRIPT_STRING( staticStr );
  1123. }
  1124. scriptVar SystemObject::vcpu_formatLongDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1125. {
  1126. SCRIPT_FUNCTION_INIT;
  1127. //CUT: int i = GET_SCRIPT_INT(_i);
  1128. time_t tt = GET_SCRIPT_INT( _i );
  1129. struct tm *t = localtime( &tt );
  1130. wcsftime( staticStr, 4096, L"%#c", t );
  1131. return MAKE_SCRIPT_STRING( staticStr );
  1132. }
  1133. scriptVar SystemObject::vcpu_getDateYear( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1134. {
  1135. SCRIPT_FUNCTION_INIT;
  1136. //CUT: int i = GET_SCRIPT_INT(_i);
  1137. time_t tt = GET_SCRIPT_INT( _i );
  1138. struct tm *t = localtime( &tt );
  1139. return MAKE_SCRIPT_INT( t->tm_year );
  1140. }
  1141. scriptVar SystemObject::vcpu_getDateMonth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1142. {
  1143. SCRIPT_FUNCTION_INIT;
  1144. //CUT: int i = GET_SCRIPT_INT(_i);
  1145. time_t tt = GET_SCRIPT_INT( _i );
  1146. struct tm *t = localtime( &tt );
  1147. return MAKE_SCRIPT_INT( t->tm_mon );
  1148. }
  1149. scriptVar SystemObject::vcpu_getDateDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1150. {
  1151. SCRIPT_FUNCTION_INIT;
  1152. //CUT: int i = GET_SCRIPT_INT(_i);
  1153. time_t tt = GET_SCRIPT_INT( _i );
  1154. struct tm *t = localtime( &tt );
  1155. return MAKE_SCRIPT_INT( t->tm_mday );
  1156. }
  1157. scriptVar SystemObject::vcpu_getDateDow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1158. {
  1159. SCRIPT_FUNCTION_INIT;
  1160. //CUT: int i = GET_SCRIPT_INT(_i);
  1161. time_t tt = GET_SCRIPT_INT( _i );
  1162. struct tm *t = localtime( &tt );
  1163. return MAKE_SCRIPT_INT( t->tm_wday );
  1164. }
  1165. scriptVar SystemObject::vcpu_getDateDoy( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1166. {
  1167. SCRIPT_FUNCTION_INIT;
  1168. //CUT: int i = GET_SCRIPT_INT(_i);
  1169. time_t tt = GET_SCRIPT_INT( _i );
  1170. struct tm *t = localtime( &tt );
  1171. return MAKE_SCRIPT_INT( t->tm_yday );
  1172. }
  1173. scriptVar SystemObject::vcpu_getDateHour( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1174. {
  1175. SCRIPT_FUNCTION_INIT;
  1176. //CUT: int i = GET_SCRIPT_INT(_i);
  1177. time_t tt = GET_SCRIPT_INT( _i );
  1178. struct tm *t = localtime( &tt );
  1179. return MAKE_SCRIPT_INT( t->tm_hour );
  1180. }
  1181. scriptVar SystemObject::vcpu_getDateMin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1182. {
  1183. SCRIPT_FUNCTION_INIT;
  1184. //CUT: int i = GET_SCRIPT_INT(_i);
  1185. time_t tt = GET_SCRIPT_INT( _i );
  1186. struct tm *t = localtime( &tt );
  1187. return MAKE_SCRIPT_INT( t->tm_min );
  1188. }
  1189. scriptVar SystemObject::vcpu_getDateSec( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1190. {
  1191. SCRIPT_FUNCTION_INIT;
  1192. //CUT: int i = GET_SCRIPT_INT(_i);
  1193. time_t tt = GET_SCRIPT_INT( _i );
  1194. struct tm *t = localtime( &tt );
  1195. return MAKE_SCRIPT_INT( t->tm_sec );
  1196. }
  1197. scriptVar SystemObject::vcpu_getDateDst( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i )
  1198. {
  1199. SCRIPT_FUNCTION_INIT;
  1200. //CUT: int i = GET_SCRIPT_INT(_i);
  1201. time_t tt = GET_SCRIPT_INT( _i );
  1202. struct tm *t = localtime( &tt );
  1203. return MAKE_SCRIPT_INT( t->tm_isdst );
  1204. }
  1205. scriptVar SystemObject::vcpu_getDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1206. {
  1207. SCRIPT_FUNCTION_INIT;
  1208. time_t t;
  1209. time( &t );
  1210. return MAKE_SCRIPT_INT( (int)t );
  1211. }
  1212. scriptVar SystemObject::vcpu_strmid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar start, scriptVar len )
  1213. {
  1214. SCRIPT_FUNCTION_INIT;
  1215. SOM::mid( staticStr, GET_SCRIPT_STRING( str ), MIN( GET_SCRIPT_INT( start ), 4096 ), MIN( GET_SCRIPT_INT( len ), 4096 ) );
  1216. return MAKE_SCRIPT_STRING( staticStr );
  1217. }
  1218. scriptVar SystemObject::vcpu_strleft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar len )
  1219. {
  1220. SCRIPT_FUNCTION_INIT;
  1221. SOM::mid( staticStr, GET_SCRIPT_STRING( str ), 0, MIN( GET_SCRIPT_INT( len ), 4096 ) );
  1222. return MAKE_SCRIPT_STRING( staticStr );
  1223. }
  1224. scriptVar SystemObject::vcpu_strright( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar _len )
  1225. {
  1226. SCRIPT_FUNCTION_INIT;
  1227. const wchar_t *str = GET_SCRIPT_STRING( _str );
  1228. int len = GET_SCRIPT_INT( _len );
  1229. SOM::mid( staticStr, str, MIN( (int)( wcslen( str ) - len ), 4096 ), MIN( len, 4096 ) );
  1230. return MAKE_SCRIPT_STRING( staticStr );
  1231. }
  1232. scriptVar SystemObject::vcpu_strsearch( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar substr )
  1233. {
  1234. SCRIPT_FUNCTION_INIT;
  1235. const wchar_t *str = GET_SCRIPT_STRING( _str );
  1236. const wchar_t *p = wcsstr( str, GET_SCRIPT_STRING( substr ) );
  1237. return MAKE_SCRIPT_INT( p ? p - str : -1 );
  1238. }
  1239. scriptVar SystemObject::vcpu_strlen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str )
  1240. {
  1241. SCRIPT_FUNCTION_INIT;
  1242. return MAKE_SCRIPT_INT( wcslen( GET_SCRIPT_STRING( str ) ) );
  1243. }
  1244. scriptVar SystemObject::vcpu_strupper( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str )
  1245. {
  1246. SCRIPT_FUNCTION_INIT;
  1247. WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1248. WCSTOUPPER( staticStr );
  1249. return MAKE_SCRIPT_STRING( staticStr );
  1250. }
  1251. scriptVar SystemObject::vcpu_strlower( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str )
  1252. {
  1253. SCRIPT_FUNCTION_INIT;
  1254. WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1255. WCSTOLOWER( staticStr );
  1256. return MAKE_SCRIPT_STRING( staticStr );
  1257. }
  1258. scriptVar SystemObject::vcpu_urlencode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str )
  1259. {
  1260. SCRIPT_FUNCTION_INIT;
  1261. StringW str( GET_SCRIPT_STRING( _str ) );
  1262. str = AutoWide( AutoUrl( str ) );
  1263. *staticStr = 0;
  1264. if ( !str.isempty() ) WCSCPYN( staticStr, str, ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1265. return MAKE_SCRIPT_STRING( staticStr );
  1266. }
  1267. scriptVar SystemObject::vcpu_urldecode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str )
  1268. {
  1269. SCRIPT_FUNCTION_INIT;
  1270. StringW str( GET_SCRIPT_STRING( _str ) );
  1271. Url::decode( str ); // Martin> I know there might be something nicer than this, but this does at least work
  1272. *staticStr = 0;
  1273. if ( !str.isempty() ) WCSCPYN( staticStr, str, ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1274. return MAKE_SCRIPT_STRING( staticStr );
  1275. }
  1276. scriptVar SystemObject::vcpu_removepath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str )
  1277. {
  1278. SCRIPT_FUNCTION_INIT;
  1279. PathParserW pp( GET_SCRIPT_STRING( _str ) );
  1280. // ASSERT(pp.getNumStrings() >= 1); // shouldn't happen ever
  1281. wchar_t *lastString = pp.getLastString();
  1282. if ( lastString )
  1283. {
  1284. WCSCPYN( staticStr, lastString, ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1285. }
  1286. else
  1287. {
  1288. staticStr[ 0 ] = 0;
  1289. }
  1290. return MAKE_SCRIPT_STRING( staticStr );
  1291. }
  1292. scriptVar SystemObject::vcpu_getpath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str )
  1293. {
  1294. SCRIPT_FUNCTION_INIT;
  1295. WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1296. #ifdef _WIN32
  1297. PathRemoveFileSpecW( staticStr );
  1298. PathRemoveBackslashW( staticStr );
  1299. #else
  1300. #warning port me
  1301. #endif
  1302. return MAKE_SCRIPT_STRING( staticStr );
  1303. }
  1304. scriptVar SystemObject::vcpu_getextension( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str )
  1305. {
  1306. SCRIPT_FUNCTION_INIT;
  1307. const wchar_t *pt = Wasabi::Std::extension( GET_SCRIPT_STRING( _str ) );
  1308. if ( pt != NULL ) WCSCPYN( staticStr, pt, ( sizeof( staticStr ) / sizeof( *staticStr ) ) );
  1309. else *staticStr = '\0';
  1310. return MAKE_SCRIPT_STRING( staticStr );
  1311. }
  1312. scriptVar SystemObject::vcpu_gettoken( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar tok, scriptVar sep, scriptVar num )
  1313. {
  1314. SCRIPT_FUNCTION_INIT;
  1315. wchar_t *p = const_cast<wchar_t *>( GET_SCRIPT_STRING( tok ) );
  1316. wchar_t *d = const_cast<wchar_t *>( GET_SCRIPT_STRING( sep ) );
  1317. int i = GET_SCRIPT_INT( num );
  1318. if ( !d ) return MAKE_SCRIPT_STRING( L"" );
  1319. if ( !p ) return MAKE_SCRIPT_STRING( L"" );
  1320. wchar_t c = *d;
  1321. d = staticStr;
  1322. int n = 0, ct = 0;
  1323. while ( p && *p && ct < 4096 )
  1324. {
  1325. if ( *p == c )
  1326. {
  1327. n++; p++; continue;
  1328. }
  1329. if ( n > i ) break;
  1330. if ( n == i )
  1331. *d++ = *p;
  1332. p++;
  1333. ct++;
  1334. }
  1335. *d = 0;
  1336. return MAKE_SCRIPT_STRING( staticStr );
  1337. }
  1338. scriptVar SystemObject::vcpu_sin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1339. {
  1340. SCRIPT_FUNCTION_INIT;
  1341. return MAKE_SCRIPT_DOUBLE( ::sin( GET_SCRIPT_DOUBLE( d ) ) );
  1342. }
  1343. scriptVar SystemObject::vcpu_cos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1344. {
  1345. SCRIPT_FUNCTION_INIT;
  1346. return MAKE_SCRIPT_DOUBLE( ::cos( GET_SCRIPT_DOUBLE( d ) ) );
  1347. }
  1348. scriptVar SystemObject::vcpu_tan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1349. {
  1350. SCRIPT_FUNCTION_INIT;
  1351. return MAKE_SCRIPT_DOUBLE( ::tan( GET_SCRIPT_DOUBLE( d ) ) );
  1352. }
  1353. scriptVar SystemObject::vcpu_asin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1354. {
  1355. SCRIPT_FUNCTION_INIT;
  1356. return MAKE_SCRIPT_DOUBLE( ::asin( GET_SCRIPT_DOUBLE( d ) ) );
  1357. }
  1358. scriptVar SystemObject::vcpu_acos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1359. {
  1360. SCRIPT_FUNCTION_INIT;
  1361. return MAKE_SCRIPT_DOUBLE( ::acos( GET_SCRIPT_DOUBLE( d ) ) );
  1362. }
  1363. scriptVar SystemObject::vcpu_atan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1364. {
  1365. SCRIPT_FUNCTION_INIT;
  1366. return MAKE_SCRIPT_DOUBLE( ::atan( GET_SCRIPT_DOUBLE( d ) ) );
  1367. }
  1368. scriptVar SystemObject::vcpu_atan2( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar y, scriptVar x )
  1369. {
  1370. SCRIPT_FUNCTION_INIT;
  1371. return MAKE_SCRIPT_DOUBLE( ::atan2( GET_SCRIPT_DOUBLE( y ), GET_SCRIPT_DOUBLE( x ) ) );
  1372. }
  1373. scriptVar SystemObject::vcpu_pow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1374. {
  1375. SCRIPT_FUNCTION_INIT;
  1376. return MAKE_SCRIPT_DOUBLE( ::pow( GET_SCRIPT_DOUBLE( x ), GET_SCRIPT_DOUBLE( y ) ) );
  1377. }
  1378. scriptVar SystemObject::vcpu_sqr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _d )
  1379. {
  1380. SCRIPT_FUNCTION_INIT;
  1381. double d = GET_SCRIPT_DOUBLE( _d );
  1382. return MAKE_SCRIPT_DOUBLE( d * d );
  1383. }
  1384. scriptVar SystemObject::vcpu_sqrt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1385. {
  1386. SCRIPT_FUNCTION_INIT;
  1387. return MAKE_SCRIPT_DOUBLE( ::sqrt( GET_SCRIPT_DOUBLE( d ) ) );
  1388. }
  1389. scriptVar SystemObject::vcpu_log10( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1390. {
  1391. SCRIPT_FUNCTION_INIT;
  1392. return MAKE_SCRIPT_DOUBLE( ::log10( GET_SCRIPT_DOUBLE( d ) ) );
  1393. }
  1394. scriptVar SystemObject::vcpu_log( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d )
  1395. {
  1396. SCRIPT_FUNCTION_INIT;
  1397. return MAKE_SCRIPT_DOUBLE( ::log( GET_SCRIPT_DOUBLE( d ) ) );
  1398. }
  1399. scriptVar SystemObject::vcpu_random( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar m )
  1400. {
  1401. SCRIPT_FUNCTION_INIT;
  1402. int m_ = GET_SCRIPT_INT( m );
  1403. return MAKE_SCRIPT_INT( m_ <= 0 ? 0 : ::rand() % m_ );
  1404. }
  1405. scriptVar SystemObject::vcpu_integer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v )
  1406. {
  1407. SCRIPT_FUNCTION_INIT;
  1408. // precision will get lost automatically
  1409. int _v = GET_SCRIPT_INT( v );
  1410. return MAKE_SCRIPT_INT( _v );
  1411. }
  1412. scriptVar SystemObject::vcpu_frac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v )
  1413. {
  1414. SCRIPT_FUNCTION_INIT;
  1415. double _v = GET_SCRIPT_DOUBLE( v ) - GET_SCRIPT_INT( v );
  1416. return MAKE_SCRIPT_DOUBLE( _v );
  1417. }
  1418. scriptVar SystemObject::vcpu_onViewPortChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar width, scriptVar height )
  1419. {
  1420. SCRIPT_FUNCTION_INIT;
  1421. PROCESS_HOOKS2( o, systemController, width, height );
  1422. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1423. SCRIPT_EXEC_EVENT2( o, width, height );
  1424. }
  1425. scriptVar SystemObject::vcpu_getViewportWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1426. {
  1427. SCRIPT_FUNCTION_INIT;
  1428. POINT pt = { 0 };
  1429. RECT r = { 0 };
  1430. Wasabi::Std::getViewport( &r, &pt );
  1431. return MAKE_SCRIPT_INT( r.right - r.left );
  1432. }
  1433. scriptVar SystemObject::vcpu_getViewportHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1434. {
  1435. SCRIPT_FUNCTION_INIT;
  1436. POINT pt = { 0 };
  1437. RECT r = { 0 };
  1438. Wasabi::Std::getViewport( &r, &pt );
  1439. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1440. }
  1441. scriptVar SystemObject::vcpu_getViewportWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1442. {
  1443. SCRIPT_FUNCTION_INIT;
  1444. RECT r = { 0 };
  1445. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1446. if ( o )
  1447. {
  1448. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() );
  1449. return MAKE_SCRIPT_INT( r.right - r.left );
  1450. }
  1451. else
  1452. {
  1453. POINT pt = { 0 };
  1454. Wasabi::Std::getViewport( &r, &pt );
  1455. return MAKE_SCRIPT_INT( r.right - r.left );
  1456. }
  1457. return MAKE_SCRIPT_INT( 0 );
  1458. }
  1459. scriptVar SystemObject::vcpu_getViewportHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1460. {
  1461. SCRIPT_FUNCTION_INIT;
  1462. RECT r = { 0 };
  1463. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1464. if ( o )
  1465. {
  1466. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() );
  1467. // benski> this prevents the window from going "fullscreen" but adds a one-line space at the bottom
  1468. RECT full = { 0 };
  1469. Wasabi::Std::getViewport( &full, o->guiobject_getRootWnd()->getOsWindowHandle(), true );
  1470. if (Wasabi::Std::rectEqual( &full, &r ) )
  1471. r.bottom--;
  1472. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1473. }
  1474. else
  1475. {
  1476. POINT pt = { 0 };
  1477. Wasabi::Std::getViewport( &r, &pt );
  1478. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1479. }
  1480. return MAKE_SCRIPT_INT( 0 );
  1481. }
  1482. scriptVar SystemObject::vcpu_getMonitorLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1483. {
  1484. SCRIPT_FUNCTION_INIT;
  1485. POINT pt = { 0 };
  1486. RECT r = { 0 };
  1487. Wasabi::Std::getViewport( &r, &pt, 1 );
  1488. return MAKE_SCRIPT_INT( r.left );
  1489. }
  1490. scriptVar SystemObject::vcpu_getMonitorLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1491. {
  1492. SCRIPT_FUNCTION_INIT;
  1493. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1494. RECT r = { 0 };
  1495. Wasabi::Std::getViewport( &r, &pt, 1 );
  1496. return MAKE_SCRIPT_INT( r.left );
  1497. }
  1498. scriptVar SystemObject::vcpu_getMonitorLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1499. {
  1500. SCRIPT_FUNCTION_INIT;
  1501. RECT r = { 0 };
  1502. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1503. if ( o )
  1504. {
  1505. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 );
  1506. return MAKE_SCRIPT_INT( r.left );
  1507. }
  1508. else
  1509. {
  1510. POINT pt = { 0 };
  1511. Wasabi::Std::getViewport( &r, &pt, 1 );
  1512. return MAKE_SCRIPT_INT( r.left );
  1513. }
  1514. return MAKE_SCRIPT_INT( 0 );
  1515. }
  1516. scriptVar SystemObject::vcpu_getMonitorTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1517. {
  1518. SCRIPT_FUNCTION_INIT;
  1519. POINT pt = { 0 };
  1520. RECT r = { 0 };
  1521. Wasabi::Std::getViewport( &r, &pt, 1 );
  1522. return MAKE_SCRIPT_INT( r.top );
  1523. }
  1524. scriptVar SystemObject::vcpu_getMonitorTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1525. {
  1526. SCRIPT_FUNCTION_INIT;
  1527. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1528. RECT r = { 0 };
  1529. Wasabi::Std::getViewport( &r, &pt, 1 );
  1530. return MAKE_SCRIPT_INT( r.top );
  1531. }
  1532. scriptVar SystemObject::vcpu_getMonitorTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1533. {
  1534. SCRIPT_FUNCTION_INIT;
  1535. RECT r = { 0 };
  1536. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1537. if ( o )
  1538. {
  1539. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 );
  1540. return MAKE_SCRIPT_INT( r.top );
  1541. }
  1542. else
  1543. {
  1544. POINT pt = { 0 };
  1545. Wasabi::Std::getViewport( &r, &pt, 1 );
  1546. return MAKE_SCRIPT_INT( r.top );
  1547. }
  1548. return MAKE_SCRIPT_INT( 0 );
  1549. }
  1550. scriptVar SystemObject::vcpu_getMonitorWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1551. {
  1552. SCRIPT_FUNCTION_INIT;
  1553. POINT pt = { 0 };
  1554. RECT r = { 0 };
  1555. Wasabi::Std::getViewport( &r, &pt, 1 );
  1556. return MAKE_SCRIPT_INT( r.right - r.left );
  1557. }
  1558. scriptVar SystemObject::vcpu_getMonitorHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1559. {
  1560. SCRIPT_FUNCTION_INIT;
  1561. POINT pt = { 0 };
  1562. RECT r = { 0 };
  1563. Wasabi::Std::getViewport( &r, &pt, 1 );
  1564. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1565. }
  1566. scriptVar SystemObject::vcpu_getMonitorWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1567. {
  1568. SCRIPT_FUNCTION_INIT;
  1569. RECT r = { 0 };
  1570. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1571. if ( o )
  1572. {
  1573. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 );
  1574. return MAKE_SCRIPT_INT( r.right - r.left );
  1575. }
  1576. else
  1577. {
  1578. POINT pt = { 0 };
  1579. Wasabi::Std::getViewport( &r, &pt, 1 );
  1580. return MAKE_SCRIPT_INT( r.right - r.left );
  1581. }
  1582. return MAKE_SCRIPT_INT( 0 );
  1583. }
  1584. scriptVar SystemObject::vcpu_getMonitorHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1585. {
  1586. SCRIPT_FUNCTION_INIT;
  1587. RECT r = { 0 };
  1588. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1589. if ( o )
  1590. {
  1591. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), true );
  1592. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1593. }
  1594. else
  1595. {
  1596. POINT pt = { 0 };
  1597. Wasabi::Std::getViewport( &r, &pt, 1 );
  1598. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1599. }
  1600. return MAKE_SCRIPT_INT( 0 );
  1601. }
  1602. scriptVar SystemObject::vcpu_getViewportLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1603. {
  1604. SCRIPT_FUNCTION_INIT;
  1605. POINT pt = { 0 };
  1606. RECT r = { 0 };
  1607. Wasabi::Std::getViewport( &r, &pt );
  1608. return MAKE_SCRIPT_INT( r.left );
  1609. }
  1610. scriptVar SystemObject::vcpu_getViewportTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1611. {
  1612. SCRIPT_FUNCTION_INIT;
  1613. POINT pt = { 0 };
  1614. RECT r = { 0 };
  1615. Wasabi::Std::getViewport( &r, &pt );
  1616. return MAKE_SCRIPT_INT( r.top );
  1617. }
  1618. scriptVar SystemObject::vcpu_getViewportLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1619. {
  1620. SCRIPT_FUNCTION_INIT;
  1621. RECT r = { 0 };
  1622. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1623. if ( o )
  1624. {
  1625. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() );
  1626. return MAKE_SCRIPT_INT( r.left );
  1627. }
  1628. else
  1629. {
  1630. POINT pt = { 0 };
  1631. Wasabi::Std::getViewport( &r, &pt );
  1632. return MAKE_SCRIPT_INT( r.left );
  1633. }
  1634. return MAKE_SCRIPT_INT( 0 );
  1635. }
  1636. scriptVar SystemObject::vcpu_getViewportTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj )
  1637. {
  1638. SCRIPT_FUNCTION_INIT;
  1639. RECT r = { 0 };
  1640. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) );
  1641. if ( o )
  1642. {
  1643. Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() );
  1644. return MAKE_SCRIPT_INT( r.top );
  1645. }
  1646. else
  1647. {
  1648. POINT pt = { 0 };
  1649. Wasabi::Std::getViewport( &r, &pt );
  1650. return MAKE_SCRIPT_INT( r.top );
  1651. }
  1652. return MAKE_SCRIPT_INT( 0 );
  1653. }
  1654. scriptVar SystemObject::vcpu_getViewportWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1655. {
  1656. SCRIPT_FUNCTION_INIT;
  1657. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1658. RECT r = { 0 };
  1659. Wasabi::Std::getViewport( &r, &pt );
  1660. return MAKE_SCRIPT_INT( r.right - r.left );
  1661. }
  1662. scriptVar SystemObject::vcpu_getMonitorHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1663. {
  1664. SCRIPT_FUNCTION_INIT;
  1665. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1666. RECT r = { 0 };
  1667. Wasabi::Std::getViewport( &r, &pt, 1 );
  1668. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1669. }
  1670. scriptVar SystemObject::vcpu_getMonitorWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1671. {
  1672. SCRIPT_FUNCTION_INIT;
  1673. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1674. RECT r = { 0 };
  1675. Wasabi::Std::getViewport( &r, &pt, 1 );
  1676. return MAKE_SCRIPT_INT( r.right - r.left );
  1677. }
  1678. scriptVar SystemObject::vcpu_getViewportHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1679. {
  1680. SCRIPT_FUNCTION_INIT;
  1681. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1682. RECT r = { 0 };
  1683. Wasabi::Std::getViewport( &r, &pt );
  1684. return MAKE_SCRIPT_INT( r.bottom - r.top );
  1685. }
  1686. scriptVar SystemObject::vcpu_getViewportLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1687. {
  1688. SCRIPT_FUNCTION_INIT;
  1689. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1690. RECT r = { 0 };
  1691. Wasabi::Std::getViewport( &r, &pt );
  1692. return MAKE_SCRIPT_INT( r.left );
  1693. }
  1694. scriptVar SystemObject::vcpu_getViewportTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y )
  1695. {
  1696. SCRIPT_FUNCTION_INIT;
  1697. POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) };
  1698. RECT r = { 0 };
  1699. Wasabi::Std::getViewport( &r, &pt );
  1700. return MAKE_SCRIPT_INT( r.top );
  1701. }
  1702. scriptVar SystemObject::vcpu_getTickCount( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1703. {
  1704. SCRIPT_FUNCTION_INIT;
  1705. return MAKE_SCRIPT_INT(Wasabi::Std::getTickCount() );
  1706. }
  1707. scriptVar SystemObject::vcpu_onKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v )
  1708. {
  1709. SCRIPT_FUNCTION_INIT;
  1710. PROCESS_HOOKS1( o, systemController, v );
  1711. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1712. SCRIPT_EXEC_EVENT1( o, v );
  1713. }
  1714. scriptVar SystemObject::vcpu_onKeyUp( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v )
  1715. {
  1716. SCRIPT_FUNCTION_INIT;
  1717. PROCESS_HOOKS1( o, systemController, v );
  1718. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1719. SCRIPT_EXEC_EVENT1( o, v );
  1720. }
  1721. scriptVar SystemObject::vcpu_debugString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar severity )
  1722. {
  1723. SCRIPT_FUNCTION_INIT;
  1724. DebugStringW( L"%s", GET_SCRIPT_STRING( str ) );
  1725. WASABI_API_SYSCB->syscb_issueCallback( SysCallback::CONSOLE, ConsoleCallback::DEBUGMESSAGE, GET_SCRIPT_INT( severity ), reinterpret_cast<intptr_t>( GET_SCRIPT_STRING( str ) ) );
  1726. return MAKE_SCRIPT_VOID();
  1727. }
  1728. scriptVar SystemObject::vcpu_messageBox( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar msg, scriptVar title, scriptVar flags, scriptVar nam )
  1729. {
  1730. SCRIPT_FUNCTION_INIT;
  1731. #ifdef WASABI_COMPILE_WNDMGR
  1732. return MAKE_SCRIPT_INT( WASABI_API_WNDMGR->messageBox( GET_SCRIPT_STRING( msg ), GET_SCRIPT_STRING( title ), GET_SCRIPT_INT( flags ), GET_SCRIPT_STRING( nam ), NULL ) );
  1733. #else
  1734. return MAKE_SCRIPT_INT( MessageBox( NULL, GET_SCRIPT_STRING( msg ), GET_SCRIPT_STRING( title ), GET_SCRIPT_INT( flags ) ) );
  1735. #endif
  1736. }
  1737. scriptVar SystemObject::vcpu_getAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname )
  1738. {
  1739. SCRIPT_FUNCTION_INIT;
  1740. return MAKE_SCRIPT_OBJECT( VCPU::getAtom( GET_SCRIPT_STRING( atomname ) ) );
  1741. }
  1742. scriptVar SystemObject::vcpu_setAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname, scriptVar obj )
  1743. {
  1744. SCRIPT_FUNCTION_INIT;
  1745. VCPU::setAtom( GET_SCRIPT_STRING( atomname ), GET_SCRIPT_OBJECT( obj ) );
  1746. RETURN_SCRIPT_VOID;
  1747. }
  1748. #ifdef WASABI_COMPILE_MAKIDEBUG
  1749. scriptVar SystemObject::vcpu_invokeDebugger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1750. {
  1751. SCRIPT_FUNCTION_INIT;
  1752. WASABI_API_MAKIDEBUG->debugger_createJITD( object->vcpu_getScriptId(), 1 );
  1753. RETURN_SCRIPT_VOID;
  1754. }
  1755. #endif
  1756. #if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  1757. scriptVar SystemObject::vcpu_onCreateLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l )
  1758. {
  1759. SCRIPT_FUNCTION_INIT;
  1760. #ifdef WASABI_COMPILE_WNDMGR
  1761. PROCESS_HOOKS1( o, systemController, l );
  1762. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1763. SCRIPT_EXEC_EVENT1( o, l );
  1764. #else
  1765. RETURN_SCRIPT_VOID;
  1766. #endif
  1767. }
  1768. scriptVar SystemObject::vcpu_onShowLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l )
  1769. {
  1770. SCRIPT_FUNCTION_INIT;
  1771. #ifdef WASABI_COMPILE_WNDMGR
  1772. PROCESS_HOOKS1( o, systemController, l );
  1773. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1774. SCRIPT_EXEC_EVENT1( o, l );
  1775. #else
  1776. RETURN_SCRIPT_VOID;
  1777. #endif
  1778. }
  1779. scriptVar SystemObject::vcpu_onHideLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l )
  1780. {
  1781. SCRIPT_FUNCTION_INIT;
  1782. #ifdef WASABI_COMPILE_WNDMGR
  1783. PROCESS_HOOKS1( o, systemController, l );
  1784. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1785. SCRIPT_EXEC_EVENT1( o, l );
  1786. #else
  1787. RETURN_SCRIPT_VOID;
  1788. #endif
  1789. }
  1790. scriptVar SystemObject::vcpu_getContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname )
  1791. {
  1792. SCRIPT_FUNCTION_INIT;
  1793. #ifdef WASABI_COMPILE_WNDMGR
  1794. Container *c = SkinParser::script_getContainer( GET_SCRIPT_STRING( contname ) );
  1795. return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL );
  1796. #else
  1797. RETURN_SCRIPT_NULL;
  1798. #endif
  1799. }
  1800. scriptVar SystemObject::vcpu_newDynamicContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname )
  1801. {
  1802. SCRIPT_FUNCTION_INIT;
  1803. #ifdef WASABI_COMPILE_WNDMGR
  1804. Container *c = SkinParser::newDynamicContainer( GET_SCRIPT_STRING( contname ) );
  1805. return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL );
  1806. #else
  1807. RETURN_SCRIPT_NULL;
  1808. #endif
  1809. }
  1810. scriptVar SystemObject::vcpu_newGroupAsLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname )
  1811. {
  1812. SCRIPT_FUNCTION_INIT;
  1813. #ifdef WASABI_COMPILE_WNDMGR
  1814. Group *g = GroupMgr::instantiate( GET_SCRIPT_STRING( groupname ), GROUP_LAYOUTGROUP );
  1815. if ( g )
  1816. {
  1817. Layout *l = static_cast<Layout *>( g );
  1818. ifc_window *par = l->getCustomOwner();
  1819. if ( !par ) par = WASABI_API_WND->main_getRootWnd();
  1820. g->setAutoResizeAfterInit( 0 );
  1821. g->setStartHidden( 1 );
  1822. g->setParent( par );
  1823. #ifdef _WIN32
  1824. g->init( hInstance, par->gethWnd(), TRUE );
  1825. #else
  1826. #warning port me
  1827. g->init( 0, par->gethWnd(), TRUE );
  1828. #endif
  1829. SystemObject *so = SOM::getSystemObjectByScriptId( __vsd );
  1830. if ( so != NULL ) so->addInstantiatedObject( g->getScriptObject() );
  1831. }
  1832. return MAKE_SCRIPT_OBJECT( g ? g->getScriptObject() : NULL );
  1833. #else
  1834. RETURN_SCRIPT_NULL;
  1835. #endif
  1836. }
  1837. scriptVar SystemObject::vcpu_getNumContainers( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1838. {
  1839. SCRIPT_FUNCTION_INIT;
  1840. #ifdef WASABI_COMPILE_WNDMGR
  1841. return MAKE_SCRIPT_INT( SkinParser::getNumContainers() );
  1842. #else
  1843. RETURN_SCRIPT_NULL;
  1844. #endif
  1845. }
  1846. scriptVar SystemObject::vcpu_enumContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n )
  1847. {
  1848. SCRIPT_FUNCTION_INIT;
  1849. #ifdef WASABI_COMPILE_WNDMGR
  1850. Container *c = SkinParser::enumContainer( GET_SCRIPT_INT( n ) );
  1851. return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL );
  1852. #else
  1853. RETURN_SCRIPT_NULL;
  1854. #endif
  1855. }
  1856. scriptVar SystemObject::vcpu_onLookForComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid )
  1857. {
  1858. SCRIPT_FUNCTION_INIT;
  1859. #ifdef WASABI_COMPILE_WNDMGR
  1860. PROCESS_HOOKS1( o, systemController, guid );
  1861. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1862. SCRIPT_EXEC_EVENT1( o, guid );
  1863. #else
  1864. RETURN_SCRIPT_VOID
  1865. #endif
  1866. }
  1867. scriptVar SystemObject::vcpu_onGetCancelComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid, scriptVar i )
  1868. {
  1869. SCRIPT_FUNCTION_INIT;
  1870. #ifdef WASABI_COMPILE_WNDMGR
  1871. PROCESS_HOOKS2( o, systemController, guid, i );
  1872. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  1873. SCRIPT_EXEC_EVENT2( o, guid, i );
  1874. #else
  1875. RETURN_SCRIPT_ZERO
  1876. #endif
  1877. }
  1878. scriptVar SystemObject::vcpu_getCurAppLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1879. {
  1880. SCRIPT_FUNCTION_INIT;
  1881. #ifdef WASABI_COMPILE_WNDMGR
  1882. RECT r = { 0 };
  1883. int s = getCurAppRect( &r );
  1884. return MAKE_SCRIPT_INT( s ? r.left : -1 );
  1885. #else
  1886. RETURN_SCRIPT_ZERO
  1887. #endif
  1888. }
  1889. scriptVar SystemObject::vcpu_getCurAppTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1890. {
  1891. SCRIPT_FUNCTION_INIT;
  1892. #ifdef WASABI_COMPILE_WNDMGR
  1893. RECT r = { 0 };
  1894. int s = getCurAppRect( &r );
  1895. return MAKE_SCRIPT_INT( s ? r.top : -1 );
  1896. #else
  1897. RETURN_SCRIPT_ZERO
  1898. #endif
  1899. }
  1900. scriptVar SystemObject::vcpu_getCurAppWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1901. {
  1902. SCRIPT_FUNCTION_INIT;
  1903. #ifdef WASABI_COMPILE_WNDMGR
  1904. RECT r = { 0 };
  1905. int s = getCurAppRect( &r );
  1906. return MAKE_SCRIPT_INT( s ? r.right - r.left : -1 );
  1907. #else
  1908. RETURN_SCRIPT_ZERO
  1909. #endif
  1910. }
  1911. scriptVar SystemObject::vcpu_getCurAppHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1912. {
  1913. SCRIPT_FUNCTION_INIT;
  1914. #ifdef WASABI_COMPILE_WNDMGR
  1915. RECT r = { 0 };
  1916. int s = getCurAppRect( &r );
  1917. return MAKE_SCRIPT_INT( s ? r.bottom - r.top : -1 );
  1918. #else
  1919. RETURN_SCRIPT_ZERO
  1920. #endif
  1921. }
  1922. scriptVar SystemObject::vcpu_isAppActive( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  1923. {
  1924. SCRIPT_FUNCTION_INIT;
  1925. #ifdef WASABI_COMPILE_WNDMGR
  1926. return MAKE_SCRIPT_BOOLEAN( isAppActive() );
  1927. #else
  1928. RETURN_SCRIPT_ZERO
  1929. #endif
  1930. }
  1931. scriptVar SystemObject::vcpu_showWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup, scriptVar prefcontainer, scriptVar transient )
  1932. {
  1933. SCRIPT_FUNCTION_INIT;
  1934. #ifdef WASABI_COMPILE_WNDMGR
  1935. const wchar_t *s = GET_SCRIPT_STRING( wndguidorgroup );
  1936. const wchar_t *p = GET_SCRIPT_STRING( prefcontainer );
  1937. int t = GET_SCRIPT_INT( transient );
  1938. if ( p != NULL && *p == 0 ) p = NULL;
  1939. GUID _g = nsGUID::fromCharW( s );
  1940. #ifdef ON_CREATE_EXTERNAL_WINDOW_GUID
  1941. if ( _g != INVALID_GUID )
  1942. {
  1943. int y = 0;
  1944. ON_CREATE_EXTERNAL_WINDOW_GUID( _g, y );
  1945. if ( y ) RETURN_SCRIPT_NULL;
  1946. }
  1947. #endif
  1948. ifc_window *ret = NULL;
  1949. if ( _g != INVALID_GUID )
  1950. ret = WASABI_API_WNDMGR->skinwnd_createByGuid( _g, p, 0, NULL, t );
  1951. else
  1952. ret = WASABI_API_WNDMGR->skinwnd_createByGroupId( s, p, 0, NULL, t );
  1953. if ( ret )
  1954. {
  1955. if ( ret->getGuiObject() )
  1956. {
  1957. return MAKE_SCRIPT_OBJECT( ret->getGuiObject()->guiobject_getScriptObject() );
  1958. }
  1959. }
  1960. #endif
  1961. RETURN_SCRIPT_NULL;
  1962. }
  1963. scriptVar SystemObject::vcpu_hideWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar hw )
  1964. {
  1965. SCRIPT_FUNCTION_INIT;
  1966. #ifdef WASABI_COMPILE_WNDMGR
  1967. GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( hw, guiObjectGuid ) );
  1968. if ( o )
  1969. WASABI_API_WNDMGR->skinwnd_destroy( o->guiobject_getRootWnd() );
  1970. #endif
  1971. RETURN_SCRIPT_NULL;
  1972. }
  1973. scriptVar SystemObject::vcpu_hideNamedWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guidorgroup )
  1974. {
  1975. SCRIPT_FUNCTION_INIT;
  1976. #ifdef WASABI_COMPILE_WNDMGR
  1977. const wchar_t *s = GET_SCRIPT_STRING( guidorgroup );
  1978. GUID _g = nsGUID::fromCharW( s );
  1979. ifc_window *w = NULL;
  1980. if ( _g != INVALID_GUID )
  1981. {
  1982. int n = WASABI_API_WNDMGR->skinwnd_getNumByGuid( _g ); // benski> CUT: int n = skinEmbedder->getNumItems(_g);
  1983. if ( n > 0 )
  1984. w = WASABI_API_WNDMGR->skinwnd_enumByGuid( _g, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(_g, n-1);
  1985. }
  1986. else
  1987. {
  1988. int n = WASABI_API_WNDMGR->skinwnd_getNumByGroupId( s ); // benski> CUT: int n = skinEmbedder->getNumItems(s);
  1989. if ( n > 0 )
  1990. w = WASABI_API_WNDMGR->skinwnd_enumByGroupId( s, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(s, n-1);
  1991. }
  1992. if ( w )
  1993. {
  1994. GuiObject *o = w->getGuiObject();
  1995. if ( o )
  1996. WASABI_API_WNDMGR->skinwnd_destroy( o->guiobject_getRootWnd() );
  1997. }
  1998. #endif
  1999. RETURN_SCRIPT_NULL;
  2000. }
  2001. scriptVar SystemObject::vcpu_isNamedWindowVisible( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guidorgroup )
  2002. {
  2003. SCRIPT_FUNCTION_INIT;
  2004. const wchar_t *s = GET_SCRIPT_STRING( guidorgroup );
  2005. GUID _g = nsGUID::fromCharW( s );
  2006. ifc_window *w = NULL;
  2007. if ( _g != INVALID_GUID )
  2008. {
  2009. int n = WASABI_API_WNDMGR->skinwnd_getNumByGuid( _g ); // benski> CUT: int n = skinEmbedder->getNumItems(_g);
  2010. if ( n > 0 )
  2011. w = WASABI_API_WNDMGR->skinwnd_enumByGuid( _g, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(_g, n-1);
  2012. }
  2013. else
  2014. {
  2015. int n = WASABI_API_WNDMGR->skinwnd_getNumByGroupId( s ); // benski> CUT: int n = skinEmbedder->getNumItems(s);
  2016. if ( n > 0 )
  2017. w = WASABI_API_WNDMGR->skinwnd_enumByGroupId( s, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(s, n-1);
  2018. }
  2019. if ( w )
  2020. {
  2021. return MAKE_SCRIPT_BOOLEAN( w->isVisible() );
  2022. }
  2023. RETURN_SCRIPT_ZERO;
  2024. }
  2025. #endif // if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2026. #if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2027. scriptVar SystemObject::vcpu_getStatus( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2028. {
  2029. SCRIPT_FUNCTION_INIT;
  2030. #ifdef WASABI_COMPILE_MEDIACORE
  2031. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getStatus( 0 ) );
  2032. #else
  2033. RETURN_SCRIPT_ZERO;
  2034. #endif
  2035. }
  2036. scriptVar SystemObject::vcpu_getSongInfoText( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2037. {
  2038. SCRIPT_FUNCTION_INIT;
  2039. #ifdef WASABI_COMPILE_MEDIACORE
  2040. #ifdef GET_SONG_INFO_TEXT
  2041. const wchar_t *c;
  2042. GET_SONG_INFO_TEXT( c );
  2043. WCSCPYN( staticStr, c, 4096 );
  2044. #else
  2045. *staticStr = 0;
  2046. #pragma CHAT("lone", "bas", "need to get the song info text, the same as would be in a text field with SONGINFO")
  2047. #endif
  2048. return MAKE_SCRIPT_STRING( staticStr );
  2049. #else
  2050. RETURN_SCRIPT_ZERO;
  2051. #endif
  2052. }
  2053. scriptVar SystemObject::vcpu_getSongInfoTextTranslated( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2054. {
  2055. SCRIPT_FUNCTION_INIT;
  2056. #ifdef WASABI_COMPILE_MEDIACORE
  2057. #ifdef GET_SONG_INFO_TEXT_TRANSLATED
  2058. const wchar_t *c;
  2059. GET_SONG_INFO_TEXT_TRANSLATED( c );
  2060. WCSCPYN( staticStr, c, 4096 );
  2061. #else
  2062. *staticStr = 0;
  2063. #endif
  2064. return MAKE_SCRIPT_STRING( staticStr );
  2065. #else
  2066. RETURN_SCRIPT_ZERO;
  2067. #endif
  2068. }
  2069. #ifdef GEN_FF
  2070. #include "../../../../Plugins/General/gen_ff/wa2frontend.h"
  2071. #endif
  2072. scriptVar SystemObject::vcpu_hasVideoSupport( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2073. {
  2074. SCRIPT_FUNCTION_INIT;
  2075. #ifdef GEN_FF
  2076. return MAKE_SCRIPT_INT( wa2.hasVideoSupport() );
  2077. #else
  2078. #pragma CHAT("lone", "bas", "how can we ask if the currently playing file is video thru the core objects ?")
  2079. RETURN_SCRIPT_ZERO;
  2080. #endif
  2081. }
  2082. scriptVar SystemObject::vcpu_isVideo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2083. {
  2084. SCRIPT_FUNCTION_INIT;
  2085. #ifdef GEN_FF
  2086. return MAKE_SCRIPT_INT( wa2.isPlayingVideo() );
  2087. #else
  2088. #pragma CHAT("lone", "bas", "how can we ask if the currently playing file is video thru the core objects ?")
  2089. RETURN_SCRIPT_ZERO;
  2090. #endif
  2091. }
  2092. scriptVar SystemObject::vcpu_isVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2093. {
  2094. SCRIPT_FUNCTION_INIT;
  2095. #ifdef GEN_FF
  2096. return MAKE_SCRIPT_INT( wa2.isPlayingVideoFullscreen() );
  2097. #else
  2098. #pragma CHAT("lone", "bas", "how can we ask if we are running fullscreen (either vis or video) ?")
  2099. RETURN_SCRIPT_ZERO;
  2100. #endif
  2101. }
  2102. scriptVar SystemObject::vcpu_setVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v )
  2103. {
  2104. SCRIPT_FUNCTION_INIT;
  2105. #ifdef GEN_FF
  2106. const bool vidfs = GET_SCRIPT_BOOLEAN( v );
  2107. if ( vidfs )
  2108. {
  2109. wa2.sendVidCmd( Winamp2FrontEnd::WA2_VIDCMD_FULLSCREEN );
  2110. }
  2111. else
  2112. {
  2113. wa2.sendVidCmd( Winamp2FrontEnd::WA2_VIDCMD_EXIT_FS );
  2114. }
  2115. return MAKE_SCRIPT_VOID();
  2116. #else
  2117. RETURN_SCRIPT_VOID;
  2118. #endif
  2119. }
  2120. scriptVar SystemObject::vcpu_getPlaylistIndex( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2121. {
  2122. SCRIPT_FUNCTION_INIT;
  2123. #ifdef GEN_FF
  2124. return MAKE_SCRIPT_INT( wa2.getCurPlaylistEntry() );
  2125. #else
  2126. #ifdef WASABI_COMPILE_MEDIACORE
  2127. return MAKE_SCRIPT_INT( CoreHandle().getCurPlaybackNumber() );
  2128. #else
  2129. RETURN_SCRIPT_ZERO;
  2130. #endif
  2131. #endif
  2132. }
  2133. scriptVar SystemObject::vcpu_getPlaylistLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2134. {
  2135. SCRIPT_FUNCTION_INIT;
  2136. #ifdef GEN_FF
  2137. return MAKE_SCRIPT_INT( wa2.getPlaylistLength() );
  2138. #else
  2139. #ifdef WASABI_COMPILE_MEDIACORE
  2140. //BU CoreHandle is your friend
  2141. return MAKE_SCRIPT_INT( CoreHandle().getNumTracks() );
  2142. #else
  2143. //FG not always, heh
  2144. RETURN_SCRIPT_ZERO;
  2145. #endif
  2146. #endif
  2147. }
  2148. scriptVar SystemObject::vcpu_getIdealVideoHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2149. {
  2150. SCRIPT_FUNCTION_INIT;
  2151. #ifdef GEN_FF
  2152. int h = -1;
  2153. wa2.getIdealVideoSize( NULL, &h );
  2154. return MAKE_SCRIPT_INT( h );
  2155. #else
  2156. #pragma CHAT("lone", "bas", "how can we ask for the ideal video size thru the core objects ?")
  2157. RETURN_SCRIPT_ZERO;
  2158. #endif
  2159. }
  2160. scriptVar SystemObject::vcpu_getIdealVideoWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2161. {
  2162. SCRIPT_FUNCTION_INIT;
  2163. #ifdef GEN_FF
  2164. int w = -1;
  2165. wa2.getIdealVideoSize( &w, NULL );
  2166. return MAKE_SCRIPT_INT( w );
  2167. #else
  2168. #pragma CHAT("lone", "bas", "how can we ask for the ideal video size thru the core objects ?")
  2169. RETURN_SCRIPT_ZERO;
  2170. #endif
  2171. }
  2172. scriptVar SystemObject::vcpu_onStop( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  2173. {
  2174. SCRIPT_FUNCTION_INIT;
  2175. #ifdef WASABI_COMPILE_MEDIACORE
  2176. PROCESS_HOOKS0( o, systemController );
  2177. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2178. SCRIPT_EXEC_EVENT0( o );
  2179. #else
  2180. RETURN_SCRIPT_VOID;
  2181. #endif
  2182. }
  2183. scriptVar SystemObject::vcpu_onShowNotification( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  2184. {
  2185. SCRIPT_FUNCTION_INIT;
  2186. #ifdef WASABI_COMPILE_MEDIACORE
  2187. PROCESS_HOOKS0( o, systemController );
  2188. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2189. SCRIPT_EXEC_EVENT0( o );
  2190. #else
  2191. RETURN_SCRIPT_VOID;
  2192. #endif
  2193. }
  2194. scriptVar SystemObject::vcpu_onPlay( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  2195. {
  2196. SCRIPT_FUNCTION_INIT;
  2197. #ifdef WASABI_COMPILE_MEDIACORE
  2198. PROCESS_HOOKS0( o, systemController );
  2199. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2200. SCRIPT_EXEC_EVENT0( o );
  2201. #else
  2202. RETURN_SCRIPT_VOID;
  2203. #endif
  2204. }
  2205. scriptVar SystemObject::vcpu_onPause( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  2206. {
  2207. SCRIPT_FUNCTION_INIT;
  2208. #ifdef WASABI_COMPILE_MEDIACORE
  2209. PROCESS_HOOKS0( o, systemController );
  2210. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2211. SCRIPT_EXEC_EVENT0( o );
  2212. #else
  2213. RETURN_SCRIPT_VOID;
  2214. #endif
  2215. }
  2216. scriptVar SystemObject::vcpu_onResume( SCRIPT_FUNCTION_PARAMS, ScriptObject *o )
  2217. {
  2218. SCRIPT_FUNCTION_INIT;
  2219. #ifdef WASABI_COMPILE_MEDIACORE
  2220. PROCESS_HOOKS0( o, systemController );
  2221. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2222. SCRIPT_EXEC_EVENT0( o );
  2223. #else
  2224. RETURN_SCRIPT_VOID;
  2225. #endif
  2226. }
  2227. scriptVar SystemObject::vcpu_onTitleChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title )
  2228. {
  2229. SCRIPT_FUNCTION_INIT;
  2230. #ifdef WASABI_COMPILE_MEDIACORE
  2231. PROCESS_HOOKS1( o, systemController, title );
  2232. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2233. SCRIPT_EXEC_EVENT1( o, title );
  2234. #else
  2235. RETURN_SCRIPT_VOID;
  2236. #endif
  2237. }
  2238. scriptVar SystemObject::vcpu_onTitle2Change( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title )
  2239. {
  2240. SCRIPT_FUNCTION_INIT;
  2241. #ifdef WASABI_COMPILE_MEDIACORE
  2242. PROCESS_HOOKS1( o, systemController, title );
  2243. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2244. SCRIPT_EXEC_EVENT1( o, title );
  2245. #else
  2246. RETURN_SCRIPT_VOID;
  2247. #endif
  2248. }
  2249. scriptVar SystemObject::vcpu_onUrlChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title )
  2250. {
  2251. SCRIPT_FUNCTION_INIT;
  2252. #ifdef WASABI_COMPILE_MEDIACORE
  2253. PROCESS_HOOKS1( o, systemController, title );
  2254. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2255. SCRIPT_EXEC_EVENT1( o, title );
  2256. #else
  2257. RETURN_SCRIPT_VOID;
  2258. #endif
  2259. }
  2260. scriptVar SystemObject::vcpu_onInfoChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info )
  2261. {
  2262. SCRIPT_FUNCTION_INIT;
  2263. #ifdef WASABI_COMPILE_MEDIACORE
  2264. PROCESS_HOOKS1( o, systemController, info );
  2265. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2266. SCRIPT_EXEC_EVENT1( o, info );
  2267. #else
  2268. RETURN_SCRIPT_VOID;
  2269. #endif
  2270. }
  2271. scriptVar SystemObject::vcpu_onStatusMsg( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info )
  2272. {
  2273. SCRIPT_FUNCTION_INIT;
  2274. #ifdef WASABI_COMPILE_MEDIACORE
  2275. PROCESS_HOOKS1( o, systemController, info );
  2276. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2277. SCRIPT_EXEC_EVENT1( o, info );
  2278. #else
  2279. RETURN_SCRIPT_VOID;
  2280. #endif
  2281. }
  2282. scriptVar SystemObject::vcpu_onEqBandChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar band, scriptVar val )
  2283. {
  2284. SCRIPT_FUNCTION_INIT;
  2285. #ifdef WASABI_COMPILE_MEDIACORE
  2286. PROCESS_HOOKS2( o, systemController, band, val );
  2287. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2288. SCRIPT_EXEC_EVENT2( o, band, val );
  2289. #else
  2290. RETURN_SCRIPT_VOID;
  2291. #endif
  2292. }
  2293. scriptVar SystemObject::vcpu_onEqFreqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val )
  2294. {
  2295. SCRIPT_FUNCTION_INIT;
  2296. #ifdef WASABI_COMPILE_MEDIACORE
  2297. PROCESS_HOOKS1( o, systemController, val );
  2298. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2299. SCRIPT_EXEC_EVENT1( o, val );
  2300. #else
  2301. RETURN_SCRIPT_VOID;
  2302. #endif
  2303. }
  2304. scriptVar SystemObject::vcpu_onEqPreAmpChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val )
  2305. {
  2306. SCRIPT_FUNCTION_INIT;
  2307. #ifdef WASABI_COMPILE_MEDIACORE
  2308. PROCESS_HOOKS1( o, systemController, val );
  2309. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2310. SCRIPT_EXEC_EVENT1( o, val );
  2311. #else
  2312. RETURN_SCRIPT_VOID;
  2313. #endif
  2314. }
  2315. scriptVar SystemObject::vcpu_onEqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val )
  2316. {
  2317. SCRIPT_FUNCTION_INIT;
  2318. #ifdef WASABI_COMPILE_MEDIACORE
  2319. PROCESS_HOOKS1( o, systemController, val );
  2320. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2321. SCRIPT_EXEC_EVENT1( o, val );
  2322. #else
  2323. RETURN_SCRIPT_VOID;
  2324. #endif
  2325. }
  2326. scriptVar SystemObject::vcpu_onVolumeChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val )
  2327. {
  2328. SCRIPT_FUNCTION_INIT;
  2329. #ifdef WASABI_COMPILE_MEDIACORE
  2330. PROCESS_HOOKS1( o, systemController, val );
  2331. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2332. SCRIPT_EXEC_EVENT1( o, val );
  2333. #else
  2334. RETURN_SCRIPT_VOID
  2335. #endif
  2336. }
  2337. scriptVar SystemObject::vcpu_onSeeked( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val )
  2338. {
  2339. SCRIPT_FUNCTION_INIT;
  2340. #ifdef WASABI_COMPILE_MEDIACORE
  2341. PROCESS_HOOKS1( o, systemController, val );
  2342. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  2343. SCRIPT_EXEC_EVENT1( o, val );
  2344. #else
  2345. RETURN_SCRIPT_VOID;
  2346. #endif
  2347. }
  2348. scriptVar SystemObject::vcpu_getPlayItemString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2349. {
  2350. SCRIPT_FUNCTION_INIT;
  2351. #ifdef WASABI_COMPILE_MEDIACORE
  2352. const wchar_t *cur = WASABI_API_MEDIACORE->core_getCurrent( 0 );
  2353. if ( cur == NULL ) cur = L"";
  2354. return MAKE_SCRIPT_STRING( cur );
  2355. #else
  2356. return MAKE_SCRIPT_STRING( L"" );
  2357. #endif
  2358. }
  2359. scriptVar SystemObject::vcpu_getPlayItemLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2360. {
  2361. SCRIPT_FUNCTION_INIT;
  2362. #ifdef WASABI_COMPILE_MEDIACORE
  2363. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getLength( 0 ) );
  2364. #else
  2365. RETURN_SCRIPT_ZERO;
  2366. #endif
  2367. }
  2368. scriptVar SystemObject::vcpu_getPlayItemDisplayTitle( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2369. {
  2370. SCRIPT_FUNCTION_INIT;
  2371. WCSCPYN( staticStr, WASABI_API_MEDIACORE->core_getTitle( 0 ), 4096 );
  2372. return MAKE_SCRIPT_STRING( staticStr );
  2373. }
  2374. scriptVar SystemObject::vcpu_getPlayItemMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar name )
  2375. {
  2376. SCRIPT_FUNCTION_INIT;
  2377. #if defined(WASABI_COMPILE_MEDIACORE) & defined(WASABI_COMPILE_METADB)
  2378. const char *cur = WASABI_API_MEDIACORE->core_getCurrent( 0 );
  2379. if ( cur == NULL ) return MAKE_SCRIPT_STRING( "" );
  2380. if ( cur && WASABI_API_METADB->metadb_getMetaData( cur, GET_SCRIPT_STRING( name ), staticStr, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ) <= 0 ) return MAKE_SCRIPT_STRING( "" );
  2381. return MAKE_SCRIPT_STRING( staticStr );
  2382. #elif defined(WASABI_CUSTOM_MINIDB)
  2383. WASABI_CUSTOM_MINIDB( GET_SCRIPT_STRING( name ), staticStr, 4096 ); staticStr[ 4095 ] = 0;
  2384. return MAKE_SCRIPT_STRING( staticStr );
  2385. #elif defined(WASABI_COMPILE_MEDIACORE)
  2386. STRNCPY( staticStr, WASABI_API_MEDIACORE->core_getCurrent( 0 ), 4095 ); staticStr[ 4095 ] = 0;
  2387. return MAKE_SCRIPT_STRING( staticStr );
  2388. #endif
  2389. }
  2390. scriptVar SystemObject::vcpu_getMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename, scriptVar name )
  2391. {
  2392. SCRIPT_FUNCTION_INIT;
  2393. wa2.getMetaData( GET_SCRIPT_STRING( filename ), GET_SCRIPT_STRING( name ), staticStr, 4096 );
  2394. return MAKE_SCRIPT_STRING( staticStr );
  2395. }
  2396. scriptVar SystemObject::vcpu_getExtFamily( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext )
  2397. {
  2398. SCRIPT_FUNCTION_INIT;
  2399. #ifdef WASABI_COMPILE_MEDIACORE
  2400. const wchar_t *ps = GET_SCRIPT_STRING( ext );
  2401. staticStr[ 0 ] = '\0';
  2402. if ( ps != NULL )
  2403. {
  2404. const wchar_t *f = WASABI_API_MEDIACORE->core_getExtensionFamily( ps );
  2405. if ( f == NULL ) f = L"";
  2406. WCSCPYN( staticStr, f, 4096 );
  2407. }
  2408. return MAKE_SCRIPT_STRING( staticStr );
  2409. #else
  2410. return MAKE_SCRIPT_STRING( L"" );
  2411. #endif
  2412. }
  2413. scriptVar SystemObject::vcpu_getDecoderName( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext )
  2414. {
  2415. SCRIPT_FUNCTION_INIT;
  2416. #ifdef WASABI_COMPILE_MEDIACORE
  2417. const wchar_t *ps = GET_SCRIPT_STRING( ext );
  2418. staticStr[ 0 ] = '\0';
  2419. if ( ps != NULL )
  2420. {
  2421. const wchar_t *f = WASABI_API_MEDIACORE->core_getDecoderName( ps );
  2422. if ( f == NULL ) f = L"";
  2423. WCSCPYN( staticStr, f, 4096 );
  2424. }
  2425. return MAKE_SCRIPT_STRING( staticStr );
  2426. #else
  2427. return MAKE_SCRIPT_STRING( L"" );
  2428. #endif
  2429. }
  2430. scriptVar SystemObject::vcpu_playFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file )
  2431. {
  2432. SCRIPT_FUNCTION_INIT;
  2433. #ifdef WASABI_COMPILE_MEDIACORE
  2434. #ifdef GEN_FF
  2435. StringW _file = GET_SCRIPT_STRING( file );
  2436. const wchar_t *f = _file.getValue();
  2437. if ( f && *f )
  2438. {
  2439. if ( wcsstr( _file, L"://" ) )
  2440. {
  2441. wa2.playFile( _file );
  2442. }
  2443. else if ( f[ 1 ] != ':' && f[ 0 ] != '\\' && f[ 0 ] != '/' )
  2444. {
  2445. PathParserW pp( f );
  2446. if ( WCSCASEEQLSAFE( pp.enumString( 0 ), L"skins" )
  2447. && WCSCASEEQLSAFE( pp.enumString( 1 ), WASABI_API_SKIN->getSkinName() ) )
  2448. {
  2449. _file = L"";
  2450. for ( int i = 0; i < pp.getNumStrings() - 2; i++ )
  2451. {
  2452. if ( i > 0 ) _file += L"\\";
  2453. _file += pp.enumString( i + 2 );
  2454. }
  2455. }
  2456. _file = StringPathCombine( WASABI_API_SKIN->getSkinPath(), _file );
  2457. if ( !WACCESS( _file, 0 ) ) // avoid clearing playlist if file not found
  2458. wa2.playFile( _file );
  2459. }
  2460. }
  2461. #else
  2462. svc_player *sp = SvcEnumByGuid<svc_player>();
  2463. if ( sp ) sp->openFile( GET_SCRIPT_STRING( file ) );
  2464. WASABI_API_SVC->service_release( sp );
  2465. #endif
  2466. return MAKE_SCRIPT_VOID();
  2467. #else
  2468. RETURN_SCRIPT_VOID;
  2469. #endif
  2470. }
  2471. scriptVar SystemObject::vcpu_enqueueFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file )
  2472. {
  2473. SCRIPT_FUNCTION_INIT;
  2474. #ifdef WASABI_COMPILE_MEDIACORE
  2475. #ifdef GEN_FF
  2476. StringW _file = GET_SCRIPT_STRING( file );
  2477. const wchar_t *f = _file.getValue();
  2478. if ( f && *f )
  2479. {
  2480. if ( wcsstr( _file, L"://" ) )
  2481. {
  2482. wa2.enqueueFile( _file );
  2483. }
  2484. else if ( f[ 1 ] != ':' && f[ 0 ] != '\\' && f[ 0 ] != '/' )
  2485. {
  2486. PathParserW pp( f );
  2487. if ( WCSCASEEQLSAFE( pp.enumString( 0 ), L"skins" )
  2488. && WCSCASEEQLSAFE( pp.enumString( 1 ), WASABI_API_SKIN->getSkinName() ) )
  2489. {
  2490. _file = L"";
  2491. for ( int i = 0; i < pp.getNumStrings() - 2; i++ )
  2492. {
  2493. if ( i > 0 ) _file += L"\\";
  2494. _file += pp.enumString( i + 2 );
  2495. }
  2496. }
  2497. _file = StringPathCombine( WASABI_API_SKIN->getSkinPath(), _file );
  2498. wa2.enqueueFile( _file );
  2499. }
  2500. }
  2501. #else
  2502. svc_player *sp = SvcEnumByGuid<svc_player>();
  2503. if ( sp ) sp->openFile( GET_SCRIPT_STRING( file ) );
  2504. WASABI_API_SVC->service_release( sp );
  2505. #endif
  2506. return MAKE_SCRIPT_VOID();
  2507. #else
  2508. RETURN_SCRIPT_VOID;
  2509. #endif
  2510. }
  2511. scriptVar SystemObject::vcpu_clearPlaylist( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2512. {
  2513. SCRIPT_FUNCTION_INIT;
  2514. wa2.clearPlaylist();
  2515. return MAKE_SCRIPT_VOID();
  2516. }
  2517. scriptVar SystemObject::vcpu_getLeftVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2518. {
  2519. SCRIPT_FUNCTION_INIT;
  2520. #ifdef WASABI_COMPILE_MEDIACORE
  2521. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getLeftVuMeter( 0 ) );
  2522. #else
  2523. RETURN_SCRIPT_ZERO;
  2524. #endif
  2525. }
  2526. scriptVar SystemObject::vcpu_getVisBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar chan, scriptVar band )
  2527. {
  2528. {
  2529. SCRIPT_FUNCTION_INIT;
  2530. #ifdef WASABI_COMPILE_MEDIACORE
  2531. unsigned char visdata[ 576 * 2 * 2 ] = { 0 };
  2532. int ret = WASABI_API_MEDIACORE->core_getVisData( 0, &visdata, sizeof( visdata ) );
  2533. if ( !ret ) MEMSET( visdata, 0, sizeof( visdata ) );
  2534. int b = MIN( MAX( 0, GET_SCRIPT_INT( band ) ), 74 );
  2535. int a = MIN( MAX( 0, GET_SCRIPT_INT( chan ) ), 1 );
  2536. return MAKE_SCRIPT_INT( MIN( 255, visdata[ 576 * a + b ] * 16 ) );
  2537. #else
  2538. RETURN_SCRIPT_ZERO;
  2539. #endif
  2540. }
  2541. }
  2542. scriptVar SystemObject::vcpu_getRightVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2543. {
  2544. SCRIPT_FUNCTION_INIT;
  2545. #ifdef WASABI_COMPILE_MEDIACORE
  2546. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getRightVuMeter( 0 ) );
  2547. #else
  2548. RETURN_SCRIPT_ZERO;
  2549. #endif
  2550. }
  2551. scriptVar SystemObject::vcpu_getVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2552. {
  2553. SCRIPT_FUNCTION_INIT;
  2554. #ifdef WASABI_COMPILE_MEDIACORE
  2555. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getVolume( 0 ) );
  2556. #else
  2557. RETURN_SCRIPT_ZERO;
  2558. #endif
  2559. }
  2560. scriptVar SystemObject::vcpu_setVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v )
  2561. {
  2562. SCRIPT_FUNCTION_INIT;
  2563. #ifdef WASABI_COMPILE_MEDIACORE
  2564. WASABI_API_MEDIACORE->core_setVolume( 0, GET_SCRIPT_INT( v ) );
  2565. return MAKE_SCRIPT_VOID();
  2566. #else
  2567. RETURN_SCRIPT_VOID;
  2568. #endif
  2569. }
  2570. scriptVar SystemObject::vcpu_play( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2571. {
  2572. SCRIPT_FUNCTION_INIT;
  2573. #ifdef WASABI_COMPILE_MEDIACORE
  2574. WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PLAY );
  2575. return MAKE_SCRIPT_VOID();
  2576. #else
  2577. RETURN_SCRIPT_VOID;
  2578. #endif
  2579. }
  2580. scriptVar SystemObject::vcpu_stop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2581. {
  2582. SCRIPT_FUNCTION_INIT;
  2583. #ifdef WASABI_COMPILE_MEDIACORE
  2584. WASABI_API_MEDIACORE->core_userButton( 0, UserButton::STOP );
  2585. return MAKE_SCRIPT_VOID();
  2586. #else
  2587. RETURN_SCRIPT_VOID;
  2588. #endif
  2589. }
  2590. scriptVar SystemObject::vcpu_pause( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2591. {
  2592. SCRIPT_FUNCTION_INIT;
  2593. #ifdef WASABI_COMPILE_MEDIACORE
  2594. WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PAUSE );
  2595. return MAKE_SCRIPT_VOID();
  2596. #else
  2597. RETURN_SCRIPT_VOID;
  2598. #endif
  2599. }
  2600. scriptVar SystemObject::vcpu_next( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2601. {
  2602. SCRIPT_FUNCTION_INIT;
  2603. #ifdef WASABI_COMPILE_MEDIACORE
  2604. WASABI_API_MEDIACORE->core_userButton( 0, UserButton::NEXT );
  2605. return MAKE_SCRIPT_VOID();
  2606. #else
  2607. RETURN_SCRIPT_VOID;
  2608. #endif
  2609. }
  2610. scriptVar SystemObject::vcpu_previous( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2611. {
  2612. SCRIPT_FUNCTION_INIT;
  2613. #ifdef WASABI_COMPILE_MEDIACORE
  2614. WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PREV );
  2615. return MAKE_SCRIPT_VOID();
  2616. #else
  2617. RETURN_SCRIPT_VOID;
  2618. #endif
  2619. }
  2620. scriptVar SystemObject::vcpu_eject( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2621. {
  2622. SCRIPT_FUNCTION_INIT;
  2623. #ifdef WASABI_COMPILE_MEDIACORE
  2624. #ifdef GEN_FF
  2625. wa2.openFileDialog( WASABI_API_WND->main_getRootWnd()->gethWnd() );
  2626. #else
  2627. svc_player *sp = SvcEnumByGuid<svc_player>();
  2628. sp->openFiles();
  2629. WASABI_API_SVC->service_release( sp );
  2630. #endif
  2631. return MAKE_SCRIPT_VOID();
  2632. #else
  2633. RETURN_SCRIPT_VOID;
  2634. #endif
  2635. }
  2636. scriptVar SystemObject::vcpu_seekTo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar to )
  2637. {
  2638. SCRIPT_FUNCTION_INIT;
  2639. #ifdef WASABI_COMPILE_MEDIACORE
  2640. WASABI_API_MEDIACORE->core_setPosition( 0, GET_SCRIPT_INT( to ) );
  2641. return MAKE_SCRIPT_VOID();
  2642. #else
  2643. RETURN_SCRIPT_VOID;
  2644. #endif
  2645. }
  2646. scriptVar SystemObject::vcpu_setEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band, scriptVar val )
  2647. {
  2648. SCRIPT_FUNCTION_INIT;
  2649. #ifdef WASABI_COMPILE_MEDIACORE
  2650. WASABI_API_MEDIACORE->core_setEqBand( 0, MAX( 0, MIN( 9, GET_SCRIPT_INT( band ) ) ), GET_SCRIPT_INT( val ) );
  2651. return MAKE_SCRIPT_VOID();
  2652. #else
  2653. RETURN_SCRIPT_VOID;
  2654. #endif
  2655. }
  2656. scriptVar SystemObject::vcpu_setEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v )
  2657. {
  2658. SCRIPT_FUNCTION_INIT;
  2659. #ifdef WASABI_COMPILE_MEDIACORE
  2660. WASABI_API_MEDIACORE->core_setEqPreamp( 0, GET_SCRIPT_INT( v ) );
  2661. return MAKE_SCRIPT_VOID();
  2662. #else
  2663. RETURN_SCRIPT_VOID;
  2664. #endif
  2665. }
  2666. scriptVar SystemObject::vcpu_setEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v )
  2667. {
  2668. SCRIPT_FUNCTION_INIT;
  2669. #ifdef WASABI_COMPILE_MEDIACORE
  2670. WASABI_API_MEDIACORE->core_setEqStatus( 0, GET_SCRIPT_INT( v ) );
  2671. return MAKE_SCRIPT_VOID();
  2672. #else
  2673. RETURN_SCRIPT_VOID;
  2674. #endif
  2675. }
  2676. scriptVar SystemObject::vcpu_getPosition( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2677. {
  2678. SCRIPT_FUNCTION_INIT;
  2679. #ifdef WASABI_COMPILE_MEDIACORE
  2680. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getPosition( 0 ) );
  2681. #else
  2682. RETURN_SCRIPT_ZERO;
  2683. #endif
  2684. }
  2685. scriptVar SystemObject::vcpu_getEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band )
  2686. {
  2687. SCRIPT_FUNCTION_INIT;
  2688. #ifdef WASABI_COMPILE_MEDIACORE
  2689. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqBand( 0, MAX( 0, MIN( 9, GET_SCRIPT_INT( band ) ) ) ) );
  2690. #else
  2691. RETURN_SCRIPT_ZERO;
  2692. #endif
  2693. }
  2694. scriptVar SystemObject::vcpu_getEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2695. {
  2696. SCRIPT_FUNCTION_INIT;
  2697. #ifdef WASABI_COMPILE_MEDIACORE
  2698. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqPreamp( 0 ) );
  2699. #else
  2700. RETURN_SCRIPT_ZERO;
  2701. #endif
  2702. }
  2703. scriptVar SystemObject::vcpu_getEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2704. {
  2705. SCRIPT_FUNCTION_INIT;
  2706. #ifdef WASABI_COMPILE_MEDIACORE
  2707. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqStatus( 0 ) );
  2708. #else
  2709. RETURN_SCRIPT_ZERO;
  2710. #endif
  2711. }
  2712. #endif // #if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2713. #if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2714. scriptVar SystemObject::vcpu_getWac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guid )
  2715. {
  2716. SCRIPT_FUNCTION_INIT;
  2717. #ifdef WASABI_COMPILE_COMPONENTS
  2718. WACObject *wo = SOM::getWACObject( GET_SCRIPT_STRING( guid ) );
  2719. return MAKE_SCRIPT_OBJECT( wo ? wo->getScriptObject() : NULL );
  2720. #else
  2721. RETURN_SCRIPT_NULL;
  2722. #endif
  2723. }
  2724. #endif // if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2725. #if defined(WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2726. scriptVar SystemObject::vcpu_setPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar str )
  2727. {
  2728. SCRIPT_FUNCTION_INIT;
  2729. #ifdef WASABI_COMPILE_CONFIG
  2730. WCSNPRINTF( staticStr, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) );
  2731. WASABI_API_CONFIG->setStringPrivate( staticStr, GET_SCRIPT_STRING( str ) );
  2732. return MAKE_SCRIPT_VOID();
  2733. #else
  2734. RETURN_SCRIPT_VOID;
  2735. #endif
  2736. }
  2737. scriptVar SystemObject::vcpu_setPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar val )
  2738. {
  2739. SCRIPT_FUNCTION_INIT;
  2740. #ifdef WASABI_COMPILE_CONFIG
  2741. WCSNPRINTF( staticStr, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) );
  2742. WASABI_API_CONFIG->setIntPrivate( staticStr, GET_SCRIPT_INT( val ) );
  2743. return MAKE_SCRIPT_VOID();
  2744. #else
  2745. RETURN_SCRIPT_VOID;
  2746. #endif
  2747. }
  2748. scriptVar SystemObject::vcpu_getPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defstr )
  2749. {
  2750. SCRIPT_FUNCTION_INIT;
  2751. #ifdef WASABI_COMPILE_CONFIG
  2752. wchar_t t[ 4096 ] = { 0 };
  2753. StringCchPrintfW( t, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) );
  2754. WASABI_API_CONFIG->getStringPrivate( t, staticStr, 4095, GET_SCRIPT_STRING( defstr ) );
  2755. return MAKE_SCRIPT_STRING( staticStr );
  2756. #else
  2757. return MAKE_SCRIPT_STRING( L"" );
  2758. #endif
  2759. }
  2760. scriptVar SystemObject::vcpu_getPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defval )
  2761. {
  2762. SCRIPT_FUNCTION_INIT;
  2763. #ifdef WASABI_COMPILE_CONFIG
  2764. wchar_t t[ 4096 ] = { 0 };
  2765. StringCchPrintfW( t, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) );
  2766. return MAKE_SCRIPT_INT( WASABI_API_CONFIG->getIntPrivate( t, GET_SCRIPT_INT( defval ) ) );
  2767. #else
  2768. RETURN_SCRIPT_ZERO;
  2769. #endif
  2770. }
  2771. scriptVar SystemObject::vcpu_setPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar str )
  2772. {
  2773. SCRIPT_FUNCTION_INIT;
  2774. #ifdef WASABI_COMPILE_CONFIG
  2775. WASABI_API_CONFIG->setStringPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_STRING( str ) );
  2776. return MAKE_SCRIPT_VOID();
  2777. #else
  2778. RETURN_SCRIPT_VOID;
  2779. #endif
  2780. }
  2781. scriptVar SystemObject::vcpu_setPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar val )
  2782. {
  2783. SCRIPT_FUNCTION_INIT;
  2784. #ifdef WASABI_COMPILE_CONFIG
  2785. WASABI_API_CONFIG->setIntPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_INT( val ) );
  2786. return MAKE_SCRIPT_VOID();
  2787. #else
  2788. RETURN_SCRIPT_VOID;
  2789. #endif
  2790. }
  2791. scriptVar SystemObject::vcpu_getPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defstr )
  2792. {
  2793. SCRIPT_FUNCTION_INIT;
  2794. #ifdef WASABI_COMPILE_CONFIG
  2795. WASABI_API_CONFIG->getStringPrivate( GET_SCRIPT_STRING( item ), staticStr, 4095, GET_SCRIPT_STRING( defstr ) );
  2796. return MAKE_SCRIPT_STRING( staticStr );
  2797. #else
  2798. return MAKE_SCRIPT_STRING( L"" );
  2799. #endif
  2800. }
  2801. scriptVar SystemObject::vcpu_getPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defval )
  2802. {
  2803. SCRIPT_FUNCTION_INIT;
  2804. #ifdef WASABI_COMPILE_CONFIG
  2805. return MAKE_SCRIPT_INT( WASABI_API_CONFIG->getIntPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_INT( defval ) ) );
  2806. #else
  2807. RETURN_SCRIPT_ZERO;
  2808. #endif
  2809. }
  2810. #endif // #if defined(WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2811. #if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE)
  2812. scriptVar SystemObject::vcpu_ddeSend( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar ddetarget, scriptVar cmd, scriptVar minInterval )
  2813. {
  2814. SCRIPT_FUNCTION_INIT;
  2815. #ifdef WA3COMPATIBILITY
  2816. DdeCom::sendCommand( GET_SCRIPT_STRING( ddetarget ), GET_SCRIPT_STRING( cmd ), GET_SCRIPT_INT( minInterval ) );
  2817. #endif
  2818. RETURN_SCRIPT_VOID;
  2819. }
  2820. scriptVar SystemObject::vcpu_popMb( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2821. {
  2822. SCRIPT_FUNCTION_INIT;
  2823. #ifdef WA3COMPATIBILITY
  2824. MainMiniBrowser::popMb();
  2825. #endif
  2826. RETURN_SCRIPT_VOID;
  2827. }
  2828. scriptVar SystemObject::vcpu_getMainMB( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2829. {
  2830. SCRIPT_FUNCTION_INIT;
  2831. #ifdef WA3COMPATIBILITY
  2832. return MAKE_SCRIPT_OBJECT( MainMiniBrowser::getScriptObject() );
  2833. #else
  2834. RETURN_SCRIPT_NULL;
  2835. #endif
  2836. }
  2837. scriptVar SystemObject::vcpu_setMenuTransparency( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar a )
  2838. {
  2839. SCRIPT_FUNCTION_INIT;
  2840. #ifdef WA3COMPATIBILITY
  2841. WASABI_API_CONFIG->setIntPublic( "Popup alpha", GET_SCRIPT_INT( a ) );
  2842. #endif
  2843. RETURN_SCRIPT_VOID;
  2844. }
  2845. scriptVar SystemObject::vcpu_windowMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2846. {
  2847. SCRIPT_FUNCTION_INIT;
  2848. #ifdef WA3COMPATIBILITY
  2849. Main::thingerContextMenu( NULL );
  2850. #endif
  2851. RETURN_SCRIPT_VOID;
  2852. }
  2853. scriptVar SystemObject::vcpu_systemMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  2854. {
  2855. SCRIPT_FUNCTION_INIT;
  2856. #ifdef WA3COMPATIBILITY
  2857. Main::appContextMenu( NULL, FALSE, FALSE );
  2858. #endif
  2859. RETURN_SCRIPT_VOID;
  2860. }
  2861. scriptVar SystemObject::vcpu_selectFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar extlist, scriptVar id, scriptVar prevfn )
  2862. {
  2863. SCRIPT_FUNCTION_INIT;
  2864. SelectFile sf( WASABI_API_WND->main_getRootWnd() );
  2865. sf.setIdent( GET_SCRIPT_STRING( id ) );
  2866. StringW ff = GET_SCRIPT_STRING( prevfn );
  2867. if ( !ff.isempty() )
  2868. {
  2869. wchar_t *p = const_cast<wchar_t *>(Wasabi::Std::filename( ff ) );
  2870. if ( p != NULL ) *p = 0;
  2871. sf.setDefaultDir( ff );
  2872. }
  2873. StringW exts = GET_SCRIPT_STRING( extlist );
  2874. if ( exts.isempty() )
  2875. exts = L"All files(*.*)|*.*||";
  2876. exts.changeChar( '|', '\0' );
  2877. int r = sf.runSelector( L"files", FALSE, exts );
  2878. StringW t;
  2879. if ( !r || sf.getNumFiles() < 1 )
  2880. {
  2881. t = GET_SCRIPT_STRING( prevfn );
  2882. }
  2883. else
  2884. {
  2885. t = sf.enumFilename( 0 );
  2886. }
  2887. WCSCPYN( staticStr, t, 4096 );
  2888. return MAKE_SCRIPT_STRING( staticStr );
  2889. }
  2890. #endif
  2891. const wchar_t *dldir;
  2892. BOOL CALLBACK browseEnumProc( HWND hwnd, LPARAM lParam )
  2893. {
  2894. wchar_t cl[ 32 ] = { 0 };
  2895. GetClassName( hwnd, cl, ARRAYSIZE( cl ) );
  2896. if ( !lstrcmpi( cl, WC_TREEVIEW ) )
  2897. {
  2898. PostMessage( hwnd, TVM_ENSUREVISIBLE, 0, (LPARAM)TreeView_GetSelection( hwnd ) );
  2899. return FALSE;
  2900. }
  2901. return TRUE;
  2902. }
  2903. static int CALLBACK BrowseCallbackProcX( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData )
  2904. {
  2905. switch ( uMsg )
  2906. {
  2907. case BFFM_INITIALIZED:
  2908. {
  2909. const wchar_t *wnd_title = (wchar_t *)lpData;
  2910. //if(wnd_title) wnd_title = _(wnd_title);
  2911. if ( WCSICMP( _( wnd_title ), L"" ) ) SetWindowTextW( hwnd, _( wnd_title ) );
  2912. SendMessageW( hwnd, BFFM_SETSELECTIONW, 1, (LPARAM)dldir );
  2913. // this is not nice but it fixes the selection not working correctly on all OSes
  2914. EnumChildWindows( hwnd, browseEnumProc, 0 );
  2915. }
  2916. return 0;
  2917. }
  2918. return 0;
  2919. }
  2920. void Shell_Free( void *p )
  2921. {
  2922. IMalloc *m;
  2923. SHGetMalloc( &m );
  2924. m->Free( p );
  2925. }
  2926. scriptVar SystemObject::vcpu_selectFolder( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar title, scriptVar info, scriptVar defPath )
  2927. {
  2928. SCRIPT_FUNCTION_INIT;
  2929. dldir = defPath.data.sdata;
  2930. BROWSEINFOW bi = { 0 };
  2931. bi.hwndOwner = WASABI_API_WND->main_getRootWnd()->gethWnd();
  2932. bi.lpszTitle = _( info.data.sdata ); // Info Text
  2933. bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  2934. bi.lpfn = BrowseCallbackProcX;
  2935. bi.lParam = (LPARAM)title.data.sdata; // Window Title
  2936. ITEMIDLIST *idlist = SHBrowseForFolderW( &bi );
  2937. if ( idlist )
  2938. {
  2939. SHGetPathFromIDListW( idlist, staticStr );
  2940. Shell_Free( idlist );
  2941. return MAKE_SCRIPT_STRING( staticStr );
  2942. }
  2943. return MAKE_SCRIPT_STRING( L"" );
  2944. }
  2945. #ifdef WASABI_COMPILE_MEDIACORE
  2946. int SystemObject::corecb_onVolumeChange( int newvol )
  2947. {
  2948. vcpu_onVolumeChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newvol ) );
  2949. return 0;
  2950. }
  2951. int SystemObject::corecb_onEQStatusChange( int newval )
  2952. {
  2953. vcpu_onEqChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) );
  2954. return 0;
  2955. }
  2956. int SystemObject::corecb_onEQPreampChange( int newval )
  2957. {
  2958. vcpu_onEqPreAmpChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) );
  2959. return 0;
  2960. }
  2961. int SystemObject::corecb_onEQBandChange( int band, int newval )
  2962. {
  2963. vcpu_onEqBandChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( band ), MAKE_SCRIPT_INT( newval ) );
  2964. return 0;
  2965. }
  2966. int SystemObject::corecb_onEQFreqChange( int newval )
  2967. {
  2968. vcpu_onEqFreqChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) );
  2969. return 0;
  2970. }
  2971. int SystemObject::corecb_onStarted()
  2972. {
  2973. vcpu_onPlay( SCRIPT_CALL, getScriptObject() );
  2974. return 0;
  2975. }
  2976. int SystemObject::corecb_onStopped()
  2977. {
  2978. vcpu_onStop( SCRIPT_CALL, getScriptObject() );
  2979. return 0;
  2980. }
  2981. int SystemObject::corecb_onPaused()
  2982. {
  2983. vcpu_onPause( SCRIPT_CALL, getScriptObject() );
  2984. return 0;
  2985. }
  2986. int SystemObject::corecb_onUnpaused()
  2987. {
  2988. vcpu_onResume( SCRIPT_CALL, getScriptObject() );
  2989. return 0;
  2990. }
  2991. int SystemObject::corecb_onSeeked( int newpos )
  2992. {
  2993. vcpu_onSeeked( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newpos ) );
  2994. return 0;
  2995. }
  2996. int SystemObject::corecb_onTitleChange( const wchar_t *title )
  2997. {
  2998. vcpu_onTitleChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( title ) );
  2999. return 0;
  3000. }
  3001. int SystemObject::corecb_onTitle2Change( const wchar_t *title )
  3002. {
  3003. vcpu_onTitle2Change( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( title ) );
  3004. return 0;
  3005. }
  3006. int SystemObject::corecb_onUrlChange( const wchar_t *url )
  3007. {
  3008. vcpu_onUrlChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( url ) );
  3009. return 0;
  3010. }
  3011. int SystemObject::corecb_onInfoChange( const wchar_t *info )
  3012. {
  3013. vcpu_onInfoChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( info ) );
  3014. return 0;
  3015. }
  3016. int SystemObject::corecb_onStatusMsg( const wchar_t *info )
  3017. {
  3018. vcpu_onStatusMsg( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( info ) );
  3019. return 0;
  3020. }
  3021. #endif
  3022. scriptVar SystemObject::vcpu_getRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  3023. {
  3024. SCRIPT_FUNCTION_INIT;
  3025. #ifdef WASABI_COMPILE_MEDIACORE
  3026. return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getRating() );
  3027. #else
  3028. RETURN_SCRIPT_ZERO;
  3029. #endif
  3030. }
  3031. scriptVar SystemObject::vcpu_setRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v )
  3032. {
  3033. SCRIPT_FUNCTION_INIT;
  3034. #ifdef WASABI_COMPILE_MEDIACORE
  3035. WASABI_API_MEDIACORE->core_setRating( GET_SCRIPT_INT( v ) );
  3036. return MAKE_SCRIPT_VOID();
  3037. #else
  3038. RETURN_SCRIPT_VOID;
  3039. #endif
  3040. }
  3041. scriptVar SystemObject::vcpu_getDownloadPath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  3042. {
  3043. SCRIPT_FUNCTION_INIT;
  3044. wa2.getDownloadPath( staticStr );
  3045. return MAKE_SCRIPT_STRING( staticStr );
  3046. }
  3047. scriptVar SystemObject::vcpu_setDownloadPath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar new_path )
  3048. {
  3049. SCRIPT_FUNCTION_INIT;
  3050. wa2.setDownloadPath( new_path.data.sdata );
  3051. return MAKE_SCRIPT_VOID();
  3052. }
  3053. scriptVar SystemObject::vcpu_downloadURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filename, scriptVar title )
  3054. {
  3055. SCRIPT_FUNCTION_INIT;
  3056. wa2.DownloadFile( AutoChar( GET_SCRIPT_STRING( url ) ) );
  3057. return MAKE_SCRIPT_VOID();
  3058. }
  3059. scriptVar SystemObject::vcpu_downloadMedia( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filepath, scriptVar storeInMl, scriptVar notifyDownloadsList )
  3060. {
  3061. SCRIPT_FUNCTION_INIT;
  3062. wa2.DownloadFile( AutoChar( GET_SCRIPT_STRING( url ) ), GET_SCRIPT_STRING( filepath ), GET_SCRIPT_BOOLEAN( storeInMl ), GET_SCRIPT_BOOLEAN( notifyDownloadsList ) );
  3063. return MAKE_SCRIPT_VOID();
  3064. }
  3065. scriptVar SystemObject::vcpu_onDownloadFinished( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url, scriptVar success, scriptVar filename )
  3066. {
  3067. SCRIPT_FUNCTION_INIT;
  3068. PROCESS_HOOKS3( o, systemController, url, success, filename );
  3069. SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o );
  3070. SCRIPT_EXEC_EVENT3( o, url, success, filename );
  3071. }
  3072. scriptVar SystemObject::vcpu_getAlbumArt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename )
  3073. {
  3074. SCRIPT_FUNCTION_INIT;
  3075. return MAKE_SCRIPT_INT( !!wa2.GetAlbumArt( GET_SCRIPT_STRING( filename ) ) );
  3076. }
  3077. scriptVar SystemObject::vcpu_isWinampPro( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  3078. {
  3079. SCRIPT_FUNCTION_INIT;
  3080. return MAKE_SCRIPT_INT( !!wa2.IsWinampPro() );
  3081. }
  3082. static PtrList<StringW> embed_guids;
  3083. static int embed_guid_enumProc( embedWindowState *ws, struct embedEnumStruct *param )
  3084. {
  3085. if ( ws->flags & EMBED_FLAGS_GUID )
  3086. {
  3087. wchar_t guid[ 39 ] = { 0 };
  3088. nsGUID::toCharW( GET_EMBED_GUID( ws ), guid );
  3089. embed_guids.addItem( new StringW( guid ) );
  3090. }
  3091. return 0;
  3092. }
  3093. scriptVar SystemObject::vcpu_enumEmbedGUID( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _index )
  3094. {
  3095. SCRIPT_FUNCTION_INIT;
  3096. int index = GET_SCRIPT_INT( _index );
  3097. if ( index == 0 ) // make the table
  3098. {
  3099. embed_guids.deleteAll();
  3100. embedEnumStruct param;
  3101. param.user_data = 0;
  3102. param.enumProc = embed_guid_enumProc;
  3103. SendMessageW( wa2.getMainWindow(), WM_WA_IPC, (WPARAM)&param, IPC_EMBED_ENUM );
  3104. }
  3105. if ( index >= 0 && index < embed_guids.getNumItems() )
  3106. return MAKE_SCRIPT_STRING( embed_guids[ index ]->getValue() );
  3107. return MAKE_SCRIPT_STRING( L"" );
  3108. }
  3109. scriptVar SystemObject::vcpu_getWinampVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  3110. {
  3111. SCRIPT_FUNCTION_INIT;
  3112. /** This would have been the code to return a double.
  3113. double r = atof(wa2.getVersion());
  3114. return MAKE_SCRIPT_DOUBLE(r);
  3115. */
  3116. return MAKE_SCRIPT_STRING( applicationApi->main_getVersionNumString() );
  3117. }
  3118. scriptVar SystemObject::vcpu_getBuildNumber( SCRIPT_FUNCTION_PARAMS, ScriptObject *object )
  3119. {
  3120. SCRIPT_FUNCTION_INIT;
  3121. return MAKE_SCRIPT_INT( applicationApi->main_getBuildNumber() );
  3122. }
  3123. scriptVar SystemObject::vcpu_getFileSize( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _file )
  3124. {
  3125. SCRIPT_FUNCTION_INIT;
  3126. const wchar_t *file = GET_SCRIPT_STRING( _file );
  3127. if ( file == NULL ) // make the table
  3128. {
  3129. return MAKE_SCRIPT_INT( 0 );
  3130. }
  3131. /*fileApi->fileOpen(file, 0);
  3132. int size = fileApi->fileGetFileSize();
  3133. fileApi->fileClose(;*/
  3134. OSFILETYPE in = WFOPEN( file, WF_READONLY_BINARY );
  3135. if ( in == OPEN_FAILED ) return MAKE_SCRIPT_INT( 0 );
  3136. int size = (int)FGETSIZE( in );
  3137. FCLOSE( in );
  3138. return MAKE_SCRIPT_INT( size );
  3139. }
  3140. wchar_t SystemObject::staticStr[ 4096 ] = { 0 };
  3141. wchar_t SystemObject::translateStr[ 4096 ] = { 0 };
  3142. PtrList < ScriptObject > SystemObject::scriptobjects;
  3143. // END VCPU
  3144. // ---------------------------------------------------------------
  3145. // -- END SCRIPT -------------------------------------------------
  3146. // ---------------------------------------------------------------