
This commit introduces a garage system to the client and updates the client's branding assets. The garage system allows players to store and retrieve vehicles. It includes the following features: - Event handling for garage requests, vehicle storage, and vehicle retrieval. - Communication with a web browser control to display garage data. - Data serialization and deserialization using JSON. The client branding has been updated with new icons and a modified `mod.cpp` file. The changes include: - Updated icons for the client. - Modified `mod.cpp` to reflect the new branding, including the mod name, picture, and DLC color.
48 lines
1.7 KiB
Plaintext
48 lines
1.7 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
[QGVAR(handleEvents), {
|
|
params ["_control", "_isConfirmDialog", "_message"];
|
|
|
|
diag_log format ["[FORGE: Garage] Received event: %1", _message];
|
|
|
|
_message = fromJSON _message;
|
|
private _event = _message get "event";
|
|
private _data = _message get "data";
|
|
|
|
private _vehicles = GETVAR(player,FORGE_Garage,[]);
|
|
|
|
switch (_event) do {
|
|
case "REQUEST_GARAGE_DATA": {
|
|
private _garageData = createHashMap;
|
|
private _vehicleList = [];
|
|
|
|
{
|
|
private _vehicle = _x;
|
|
if (isNull _vehicle || { !alive _vehicle }) exitWith {};
|
|
|
|
private _vehicleInfo = createHashMapFromArray [
|
|
["classname", typeOf _vehicle],
|
|
["damage", damage _vehicle],
|
|
["fuel", fuel _vehicle],
|
|
["hitpoints", getAllHitPointsDamage _vehicle]
|
|
];
|
|
|
|
_vehicleList pushBack _vehicleInfo;
|
|
} forEach _vehicles;
|
|
|
|
_garageData set ["vehicles", _vehicleList];
|
|
_control ctrlWebBrowserAction ["ExecJS", format ["handleGarageDataRequest(%1)", (toJSON _vehicleList)]];
|
|
};
|
|
case "STORE_VEHICLE": {
|
|
// Logic to store vehicle in garage
|
|
// This would typically involve saving the vehicle's state to a database or similar
|
|
};
|
|
case "RETRIEVE_VEHICLE": {
|
|
// Logic to retrieve vehicle from garage
|
|
// This would typically involve loading the vehicle's state from a database or similar
|
|
};
|
|
default {
|
|
diag_log format ["[FORGE: Garage] Unknown event: %1", _event];
|
|
};
|
|
};
|
|
}] call CFUNC(addEventHandler); |