diff --git a/docs/Scratchie/installation.md b/docs/Scratchie/installation.md new file mode 100644 index 0000000..eb1fc24 --- /dev/null +++ b/docs/Scratchie/installation.md @@ -0,0 +1,45 @@ +# Introduction + +PLEASE NOTE THIS GUIDE ONLY COVERES THE ExAd MISSION FILE INSTALLATION.
+THE MISSING SERVER AND DATABASE INSTRUCTION CAN BE FOUND [HERE](https://github.com/ole1986/a3-exile-scratchie/tree/ExAd) + +**Requirements** + +Please note that the Scratchie plugin has the following ExAd dependencies + +* Core +* XM8 + +**Installation** + +* Copy the folder "source\ExAdClient\Scratchie" into "mpmissions\exile.\ExAdClient" + +* Open the "mpmissions\exile.\ExAdClient\CfgFunctions.cpp" and add the following line inside `class ExAd` + +``` +#include "Scratchie\CfgFunctions.cpp" +``` + +* Amend the `class CfgXM8` from "mpmissions\exile.\config.cpp" the following (to make Scratchie app available in XM8) + +``` +class CfgXM8 { + extraApps[] = {"ExAd_Scratchie"}; + + class ExAd_Scratchie + { + title = "Play Scratchie"; + controlID = 80000; + logo = "ExAdClient\Scratchie\icons\scratchie.paa"; + onLoad = "ExAdClient\Scratchie\onLoad.sqf"; + onOpen = "ExAdClient\Scratchie\onOpen.sqf"; + onClose = "ExAdClient\Scratchie\onClose.sqf"; + }; +} +``` + +* Customize the "mpmissions\exile.\description.ext" by adding the below line into `class CfgRemoteExec` -> `class Functions` + +``` +class ExileServer_lottery_network_request { allowedTargets = 2; } +``` \ No newline at end of file diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/CfgFunctions.cpp b/mpmissions/Exile.Altis/ExAdClient/Scratchie/CfgFunctions.cpp new file mode 100644 index 0000000..730682e --- /dev/null +++ b/mpmissions/Exile.Altis/ExAdClient/Scratchie/CfgFunctions.cpp @@ -0,0 +1,3 @@ +class Scratchie { + class postInitScratchie {file = "ExAdClient\Scratchie\postInit.sqf"; postInit = 1;}; +} \ No newline at end of file diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie-buy.paa b/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie-buy.paa new file mode 100644 index 0000000..ce9cac3 Binary files /dev/null and b/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie-buy.paa differ diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie-prize.paa b/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie-prize.paa new file mode 100644 index 0000000..12b20bd Binary files /dev/null and b/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie-prize.paa differ diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie.paa b/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie.paa new file mode 100644 index 0000000..791ee31 Binary files /dev/null and b/mpmissions/Exile.Altis/ExAdClient/Scratchie/icons/scratchie.paa differ diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/onClose.sqf b/mpmissions/Exile.Altis/ExAdClient/Scratchie/onClose.sqf new file mode 100644 index 0000000..19b7e03 --- /dev/null +++ b/mpmissions/Exile.Altis/ExAdClient/Scratchie/onClose.sqf @@ -0,0 +1,4 @@ +if (ExileClientXM8CurrentSlide == "ExAd_Scratchie") then { + ExileClientXM8CurrentSlide = "apps"; +}; +ExAdCurFlagNetId = nil; \ No newline at end of file diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/onLoad.sqf b/mpmissions/Exile.Altis/ExAdClient/Scratchie/onLoad.sqf new file mode 100644 index 0000000..bd466e7 --- /dev/null +++ b/mpmissions/Exile.Altis/ExAdClient/Scratchie/onLoad.sqf @@ -0,0 +1,51 @@ +/* + onLoad.sqf + + Copyright 2017 ole + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +params["_display","_slide","_idc"]; + +_pW = 0.025; +_pH = 0.04; +_leftCol = 0; +_leftColW = 10; + +_margin = 0.02; + +_posX = _margin + _leftCol * _pW; + +_slideClass = "ExAd_Scratchie"; + +// fixing index issue from ExAd_fnc_getNextIDC and ExAd_fnc_getAppCtrl +[_slideClass,"dummy"] call ExAd_fnc_getNextIDC; + +[_display,_slide,([_slideClass,"InfoTitle"] call ExAd_fnc_getNextIDC),[_leftCol * _pW, 2.75 * _pH, 20 * _pW, 2 * _pH],"Counting Scratchies...","PuristaMedium",1.2,"#ffffff","left",1] call ExAd_fnc_createStructuredText; +[_display,_slide,([_slideClass,"backButton"] call ExAd_fnc_getNextIDC),[27.6 * _pW, 17.7 * _pH, 6 * _pW, 1 * _pH],'["extraApps", 1] call ExileClient_gui_xm8_slide;','Back'] call ExAd_fnc_createButton; + +/* Buy button */ +[_display,_slide,([_slideClass,"picBuy"] call ExAd_fnc_getNextIDC),[_posX, 5 * _pH, _leftColW * _pW, 7 * _pH],"ExAdClient\Scratchie\icons\scratchie-buy.paa",[1,1,1,1],false,false,""] call ExAd_fnc_createPicture; +[_display,_slide,([_slideClass,"buyButton"] call ExAd_fnc_getNextIDC),[_posX, 12 * _pH, _leftColW*_pW, 1*_pH],"['buy',ExileClientSessionId, player, ''] remoteExecCall ['ExileServer_lottery_network_request', 2]; [] spawn Scratchie_UpdateCount;",'Buy Scratchie',""] call ExAd_fnc_createButton; + +/* Use button */ +_posX = _posX + _margin + _leftColW * _pW; +[_display,_slide,([_slideClass,"picUse"] call ExAd_fnc_getNextIDC),[_posX, 5 * _pH, _leftColW * _pW, 7 * _pH],"ExAdClient\Scratchie\icons\scratchie.paa",[1,1,1,1],false,false,""] call ExAd_fnc_createPicture; +[_display,_slide,([_slideClass,"useButton"] call ExAd_fnc_getNextIDC),[_posX, 12 * _pH, _leftColW * _pW, 1 * _pH],"['use',ExileClientSessionId, player, ''] remoteExecCall ['ExileServer_lottery_network_request', 2]; [] spawn Scratchie_UpdateCount;",'Use Scratchie',""] call ExAd_fnc_createButton; + +/* Get Prize button */ +_posX = _posX + _margin + _leftColW * _pW; +[_display,_slide,([_slideClass,"picPrize"] call ExAd_fnc_getNextIDC),[_posX, 5 * _pH, _leftColW * _pW, 7 * _pH],"ExAdClient\Scratchie\icons\scratchie-prize.paa",[1,1,1,1],false,false,""] call ExAd_fnc_createPicture; +[_display,_slide,([_slideClass,"useButton"] call ExAd_fnc_getNextIDC),[_posX, 12 * _pH, _leftColW * _pW, 1 * _pH],"['get',ExileClientSessionId, player, ''] remoteExecCall ['ExileServer_lottery_network_request', 2];",'Get Prize',""] call ExAd_fnc_createButton; + +true \ No newline at end of file diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/onOpen.sqf b/mpmissions/Exile.Altis/ExAdClient/Scratchie/onOpen.sqf new file mode 100644 index 0000000..9e522a1 --- /dev/null +++ b/mpmissions/Exile.Altis/ExAdClient/Scratchie/onOpen.sqf @@ -0,0 +1,18 @@ +private ["_flags","_flag"]; + +try +{ + _display = uiNameSpace getVariable ["RscExileXM8", displayNull]; + if(isNull _display)exitWith{ + throw "XM8 not loaded!"; + }; + + diag_log "Opening Scratchies slide"; + + [] spawn Scratchie_UpdateCount; +} +catch +{ + ["ErrorTitleAndText", ["ExAd - Scratchies", _exception]] call ExileClient_gui_toaster_addTemplateToast; + ["extraApps", 1] call ExileClient_gui_xm8_slide +} \ No newline at end of file diff --git a/mpmissions/Exile.Altis/ExAdClient/Scratchie/postInit.sqf b/mpmissions/Exile.Altis/ExAdClient/Scratchie/postInit.sqf new file mode 100644 index 0000000..c9931f0 --- /dev/null +++ b/mpmissions/Exile.Altis/ExAdClient/Scratchie/postInit.sqf @@ -0,0 +1,34 @@ +/* + postInit.sqf - Scratchie postInit used for ExAd + + Copyright 2017 - ole1986 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +if (isDedicated) exitWith {}; + +private _code = { + disableSerialization; + + private _display = uiNameSpace getVariable ["RscExileXM8", displayNull]; + private _ctrl = [_display,"ExAd_Scratchie","InfoTitle"] call ExAd_fnc_getAppCtrl; + + _ctrl ctrlSetStructuredText parseText "Counting Scratchies..."; + sleep 3; + _ctrl ctrlSetStructuredText parseText (format ["You have %1 Scratchies in your pocket", missionNamespace getVariable ["scratchieCount", 0]]); +}; + +missionNamespace setVariable ['Scratchie_UpdateCount', _code]; + +diag_log "Loaded Scratchie postInit"; \ No newline at end of file