mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 02:32:29 +01:00
Add args parsing
Add access to ScreenPlay object to the fjord example
This commit is contained in:
parent
0e05ec1188
commit
a596ad6337
26
Content/wallpaper_godot_fjord/Action.gd
Normal file
26
Content/wallpaper_godot_fjord/Action.gd
Normal file
@ -0,0 +1,26 @@
|
||||
extends Node
|
||||
|
||||
# Reference to the PathFollow node
|
||||
@onready var path_follow = $Path3D/PathFollow3D
|
||||
@onready var label = $Label3D
|
||||
var debug_path
|
||||
var screenplaywallpaper
|
||||
var appID = ""
|
||||
# Speed of the movement along the path
|
||||
var speed = 0.8
|
||||
|
||||
|
||||
func _process(delta):
|
||||
# Update the offset to move the object along the path
|
||||
path_follow.progress += speed * delta
|
||||
|
||||
# Loop back to the start if we've reached the end of the path
|
||||
if path_follow.progress >= 18.81:
|
||||
path_follow.progress = 0.0
|
||||
|
||||
screenplaywallpaper = get_node("/root/Wallpaper/ScreenPlayGodotWallpaper")
|
||||
if screenplaywallpaper:
|
||||
appID = screenplaywallpaper.get_appID()
|
||||
else:
|
||||
appID = "404"
|
||||
label.text = "Godot Wallpaper\n" + Time.get_time_string_from_system() + "\nAppID: " + appID
|
@ -2,14 +2,16 @@ extends Path3D
|
||||
|
||||
# Reference to the PathFollow node
|
||||
@onready var path_follow = $PathFollow3D
|
||||
@onready var path_follow =
|
||||
|
||||
# Speed of the movement along the path
|
||||
var speed = 0.4
|
||||
var speed = 0.8
|
||||
|
||||
|
||||
func _process(delta):
|
||||
# Update the offset to move the object along the path
|
||||
path_follow.progress += speed * delta
|
||||
|
||||
# Loop back to the start if we've reached the end of the path
|
||||
if path_follow.progress > 10:
|
||||
if path_follow.progress >= 18.81:
|
||||
path_follow.progress = 0.0
|
||||
|
34
Content/wallpaper_godot_fjord/preview.png.import
Normal file
34
Content/wallpaper_godot_fjord/preview.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b50wk45iaak85"
|
||||
path="res://.godot/imported/preview.png-b4838d23de224c84c7c9b5588b6708a6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://preview.png"
|
||||
dest_files=["res://.godot/imported/preview.png-b4838d23de224c84c7c9b5588b6708a6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
@ -1,35 +1,38 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cxlfu6y6b3l5o"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dp883pjlm7gk8"]
|
||||
|
||||
[ext_resource type="Script" path="res://Path3D.gd" id="1_76sq1"]
|
||||
[ext_resource type="Script" path="res://Action.gd" id="1_p251a"]
|
||||
|
||||
[sub_resource type="Curve3D" id="Curve3D_8adw4"]
|
||||
bake_interval = 2.4
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, -0.820513, 0.281883, 0.141011, 0, 0, 0, 0, 0, 0, -0.1735, 0.399895, -0.280881, 0, 0, 0, 0, 0, 0, 0.510953, 0.524736, -0.727188, 0, 0, 0, 0, 0, 0, 2.26923, 2.38419e-07, -1.10178, 0, 0, 0, 0, 0, 0, 2.53764, -0.832639, -0.471864, 0, 0, 0, 0, 0, 0, 0.836093, -1.07116, 0.572063, 0, 0, 0, 0, 0, 0, -0.416085, -0.732896, 0.871186, 0, 0, 0, 0, 0, 0, -0.809435, -0.0867326, 0.472196),
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2.82099, -0.143238, -1.14419, 0, 0, 0, 0, 0, 0, -0.837192, 0.205974, -1.5077, 0, 0, 0, 0, 0, 0, 2.26923, 2.38419e-07, -1.10178, 0, 0, 0, 0, 0, 0, 3.0406, -0.00296563, 0.345948, 0, 0, 0, 0, 0, 0, 0.398976, -0.117547, 1.42909, 0, 0, 0, 0, 0, 0, -2.74903, -0.071628, 0.795209, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
||||
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0)
|
||||
}
|
||||
point_count = 8
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0123152, 0)
|
||||
script = ExtResource("1_p251a")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.04825, 4.0185)
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.093655, 0)
|
||||
size = Vector3(5.24075, 0.0764128, 3.72353)
|
||||
transform = Transform3D(3.5774, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.223695, 0)
|
||||
size = Vector3(7.59119, 0.0764128, 5.75358)
|
||||
|
||||
[node name="Path3D" type="Path3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1394, 0, 0.705414)
|
||||
curve = SubResource("Curve3D_8adw4")
|
||||
script = ExtResource("1_76sq1")
|
||||
|
||||
[node name="PathFollow3D" type="PathFollow3D" parent="Path3D"]
|
||||
transform = Transform3D(0.546201, -0.126512, -0.828045, 7.45058e-09, 0.988529, -0.151031, 0.837654, 0.0824935, 0.539936, -0.820513, 0.281883, 0.141011)
|
||||
transform = Transform3D(0.375854, -0.0435545, 0.925652, -3.72525e-09, 0.998895, 0.0470007, -0.926666, -0.0176657, 0.375443, 0, 0, 0)
|
||||
|
||||
[node name="OmniLight3D" type="OmniLight3D" parent="Path3D/PathFollow3D"]
|
||||
light_color = Color(0.921569, 0.52549, 0.32549, 1)
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.391226, -1.25994)
|
||||
transform = Transform3D(0.997247, 0, 0, 0, 0.997247, 0, 0, 0, 0.997247, 0.030704, 1.238, -1.40679)
|
||||
shaded = true
|
||||
text = "GODO WALLPAPER"
|
||||
font_size = 126
|
||||
|
@ -470,7 +470,7 @@ private:
|
||||
bool m_checkWallpaperVisible { false };
|
||||
bool m_silentStart { false };
|
||||
bool m_anonymousTelemetry { true };
|
||||
bool m_showDefaultContent { false };
|
||||
bool m_showDefaultContent { true };
|
||||
|
||||
QString m_decoder;
|
||||
ScreenPlay::FillMode::FillMode m_videoFillMode { ScreenPlay::FillMode::FillMode::Cover };
|
||||
|
@ -306,10 +306,8 @@ bool ScreenPlayWallpaper::exportGodotProject(const QString& absolutePath, int ti
|
||||
process.setProgram(m_globalVariables->godotEditorExecutablePath().toString());
|
||||
// Start the Godot export process
|
||||
process.setArguments(godotCmd);
|
||||
if (!process.startDetached()) {
|
||||
qCritical() << "Godot failed to start.";
|
||||
return false;
|
||||
}
|
||||
process.start();
|
||||
|
||||
// Wait for the process to finish or timeout
|
||||
if (!process.waitForFinished(timeoutMilliseconds)) {
|
||||
qCritical() << "Godot export process timed out or failed to start.";
|
||||
|
@ -9,14 +9,30 @@
|
||||
#include "godot_cpp/variant/utility_functions.hpp"
|
||||
|
||||
//// ScreenPlayWallpaper
|
||||
|
||||
using namespace godot;
|
||||
int ScreenPlayGodotWallpaper::sInstanceCount = 0;
|
||||
int ScreenPlayGodotWallpaper::sLastID = 0;
|
||||
|
||||
void ScreenPlayGodotWallpaper::_bind_methods()
|
||||
{
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("init"), &ScreenPlayGodotWallpaper::init);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("create_named_pipe"), &ScreenPlayGodotWallpaper::create_named_pipe);
|
||||
UtilityFunctions::print("ScreenPlayGodotWallpaper _bind_methods");
|
||||
ClassDB::bind_method(godot::D_METHOD("init"), &ScreenPlayGodotWallpaper::init);
|
||||
ClassDB::bind_method(godot::D_METHOD("connect_to_named_pipe"), &ScreenPlayGodotWallpaper::connect_to_named_pipe);
|
||||
|
||||
ClassDB::bind_method(godot::D_METHOD("get_activeScreensList"), &ScreenPlayGodotWallpaper::get_activeScreensList);
|
||||
ClassDB::bind_method(godot::D_METHOD("set_activeScreensList", "screens"), &ScreenPlayGodotWallpaper::set_activeScreensList);
|
||||
|
||||
ClassDB::bind_method(godot::D_METHOD("get_projectPath"), &ScreenPlayGodotWallpaper::get_projectPath);
|
||||
ClassDB::bind_method(godot::D_METHOD("set_projectPath", "path"), &ScreenPlayGodotWallpaper::set_projectPath);
|
||||
|
||||
ClassDB::bind_method(godot::D_METHOD("get_appID"), &ScreenPlayGodotWallpaper::get_appID);
|
||||
ClassDB::bind_method(godot::D_METHOD("set_appID", "id"), &ScreenPlayGodotWallpaper::set_appID);
|
||||
|
||||
ClassDB::bind_method(godot::D_METHOD("get_volume"), &ScreenPlayGodotWallpaper::get_volume);
|
||||
ClassDB::bind_method(godot::D_METHOD("set_volume", "volume"), &ScreenPlayGodotWallpaper::set_volume);
|
||||
|
||||
ClassDB::bind_method(godot::D_METHOD("get_checkWallpaperVisible"), &ScreenPlayGodotWallpaper::get_checkWallpaperVisible);
|
||||
ClassDB::bind_method(godot::D_METHOD("set_checkWallpaperVisible", "visible"), &ScreenPlayGodotWallpaper::set_checkWallpaperVisible);
|
||||
}
|
||||
|
||||
void ScreenPlayGodotWallpaper::hideFromTaskbar(HWND hwnd)
|
||||
@ -32,17 +48,17 @@ ScreenPlayGodotWallpaper::ScreenPlayGodotWallpaper()
|
||||
mID = ++sLastID;
|
||||
sInstanceCount++;
|
||||
|
||||
godot::UtilityFunctions::print(
|
||||
"ScreenPlayWallpaper ", godot::itos(mID),
|
||||
" created, current instance count: ", godot::itos(sInstanceCount));
|
||||
UtilityFunctions::print(
|
||||
"ScreenPlayWallpaper ", itos(mID),
|
||||
" created, current instance count: ", itos(sInstanceCount));
|
||||
}
|
||||
|
||||
ScreenPlayGodotWallpaper::~ScreenPlayGodotWallpaper()
|
||||
{
|
||||
sInstanceCount--;
|
||||
godot::UtilityFunctions::print(
|
||||
"ScreenPlayWallpaper ", godot::itos(mID),
|
||||
" destroyed, current instance count: ", godot::itos(sInstanceCount));
|
||||
UtilityFunctions::print(
|
||||
"ScreenPlayWallpaper ", itos(mID),
|
||||
" destroyed, current instance count: ", itos(sInstanceCount));
|
||||
|
||||
// Somehow this gets called at editor startup
|
||||
// so just return if not initialized
|
||||
@ -56,38 +72,38 @@ ScreenPlayGodotWallpaper::~ScreenPlayGodotWallpaper()
|
||||
ShowWindow(m_hook->windowHandleWorker, SW_SHOW);
|
||||
}
|
||||
// Destructor
|
||||
if (hPipe != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(hPipe);
|
||||
if (m_hPipe != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(m_hPipe);
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlayGodotWallpaper::_process(double delta)
|
||||
{
|
||||
|
||||
if (!isPipeActive) {
|
||||
return;
|
||||
}
|
||||
timesinceLastRead += delta;
|
||||
// 0.05 seconds = 50ms
|
||||
if (timesinceLastRead >= 0.05) {
|
||||
godot::String data = read_from_pipe();
|
||||
if (!data.is_empty()) {
|
||||
godot::UtilityFunctions::print("Received data: " + data);
|
||||
}
|
||||
timesinceLastRead = 0.0;
|
||||
}
|
||||
// if (!isPipeActive) {
|
||||
// return;
|
||||
// }
|
||||
// timesinceLastRead += delta;
|
||||
// // 0.05 seconds = 50ms
|
||||
// if (timesinceLastRead >= 0.05) {
|
||||
// String data = read_from_pipe();
|
||||
// if (!data.is_empty()) {
|
||||
// UtilityFunctions::print("Received data: " + data);
|
||||
// }
|
||||
// timesinceLastRead = 0.0;
|
||||
// }
|
||||
}
|
||||
|
||||
bool ScreenPlayGodotWallpaper::configureWindowGeometry()
|
||||
{
|
||||
if (!m_hook->searchWorkerWindowToParentTo()) {
|
||||
godot::UtilityFunctions::print("No worker window found");
|
||||
UtilityFunctions::print("No worker window found");
|
||||
return false;
|
||||
}
|
||||
|
||||
RECT rect {};
|
||||
if (!GetWindowRect(m_hook->windowHandleWorker, &rect)) {
|
||||
godot::UtilityFunctions::print("Unable to get WindoeRect from worker");
|
||||
UtilityFunctions::print("Unable to get WindoeRect from worker");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -104,7 +120,7 @@ bool ScreenPlayGodotWallpaper::configureWindowGeometry()
|
||||
|
||||
bool ScreenPlayGodotWallpaper::init(int activeScreen)
|
||||
{
|
||||
auto* displayServer = godot::DisplayServer::get_singleton();
|
||||
auto* displayServer = DisplayServer::get_singleton();
|
||||
int64_t handle_int = displayServer->window_get_native_handle(godot::DisplayServer::HandleType::WINDOW_HANDLE, activeScreen);
|
||||
HWND hwnd = reinterpret_cast<HWND>(static_cast<intptr_t>(handle_int));
|
||||
m_hook = std::make_unique<WindowsHook>();
|
||||
@ -126,56 +142,52 @@ bool ScreenPlayGodotWallpaper::init(int activeScreen)
|
||||
const int x = monitors.rcMonitors[activeScreen].left + m_hook->zeroPoint.x + borderOffset; // Assuming m_zeroPoint is a POINT struct
|
||||
const int y = monitors.rcMonitors[activeScreen].top + m_hook->zeroPoint.y + borderOffset;
|
||||
|
||||
godot::String output = "Setup window activeScreen: " + godot::itos(activeScreen) + " scaling: " + godot::rtos(scaling) + " x: " + godot::itos(x) + " y: " + godot::itos(y) + " width: " + godot::itos(width) + " height: " + godot::itos(height);
|
||||
godot::UtilityFunctions::print(output);
|
||||
String output = "Setup window activeScreen: " + itos(activeScreen) + " scaling: " + rtos(scaling) + " x: " + itos(x) + " y: " + itos(y) + " width: " + itos(width) + " height: " + itos(height);
|
||||
UtilityFunctions::print(output);
|
||||
|
||||
// Must be called twice for some reason when window has scaling...
|
||||
if (!SetWindowPos(m_hook->windowHandle, nullptr, x, y, width, height, SWP_HIDEWINDOW)) {
|
||||
godot::UtilityFunctions::print("Could not set window pos");
|
||||
UtilityFunctions::print("Could not set window pos");
|
||||
return false;
|
||||
}
|
||||
if (!SetWindowPos(m_hook->windowHandle, nullptr, x, y, width, height, SWP_HIDEWINDOW)) {
|
||||
godot::UtilityFunctions::print("Could not set window pos 2");
|
||||
UtilityFunctions::print("Could not set window pos 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SetParent(m_hook->windowHandle, m_hook->windowHandleWorker) == nullptr) {
|
||||
godot::UtilityFunctions::print("Could not attach to parent window");
|
||||
UtilityFunctions::print("Could not attach to parent window");
|
||||
return false;
|
||||
}
|
||||
displayServer->window_set_size(godot::Vector2((real_t)width, (real_t)height));
|
||||
ShowWindow(m_hook->windowHandle, SW_SHOW);
|
||||
const std::string windowTitle = "ScreenPlayWallpaperGodot";
|
||||
SetWindowText(hwnd, windowTitle.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScreenPlayGodotWallpaper::create_named_pipe(godot::String pipeName)
|
||||
bool ScreenPlayGodotWallpaper::connect_to_named_pipe()
|
||||
{
|
||||
godot::String fullPipeName = "\\\\.\\pipe\\" + pipeName;
|
||||
String pipeName = "ScreenPlay";
|
||||
String fullPipeName = "\\\\.\\pipe\\" + pipeName;
|
||||
std::wstring wPipeName = std::wstring(fullPipeName.wide_string());
|
||||
|
||||
hPipe = CreateNamedPipeW(
|
||||
m_hPipe = CreateFileW(
|
||||
wPipeName.c_str(),
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
|
||||
1,
|
||||
1024 * 16,
|
||||
1024 * 16,
|
||||
NMPWAIT_USE_DEFAULT_WAIT,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
if (hPipe == INVALID_HANDLE_VALUE) {
|
||||
isPipeActive = false;
|
||||
godot::UtilityFunctions::print("CreateNamedPipe failed, error code: " + godot::String::num_int64(GetLastError()));
|
||||
if (m_hPipe == INVALID_HANDLE_VALUE) {
|
||||
m_isPipeActive = false;
|
||||
UtilityFunctions::print("CreateFile failed, error code: " + String::num_int64(GetLastError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ConnectNamedPipe(hPipe, NULL) == FALSE) {
|
||||
CloseHandle(hPipe);
|
||||
godot::UtilityFunctions::print("ConnectNamedPipe failed, error code: " + godot::String::num_int64(GetLastError()));
|
||||
isPipeActive = false;
|
||||
return false;
|
||||
}
|
||||
isPipeActive = true;
|
||||
m_isPipeActive = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -183,14 +195,108 @@ godot::String ScreenPlayGodotWallpaper::read_from_pipe()
|
||||
{
|
||||
char buffer[128];
|
||||
DWORD bytesRead;
|
||||
godot::String result;
|
||||
String result;
|
||||
|
||||
if (ReadFile(hPipe, buffer, sizeof(buffer) - 1, &bytesRead, NULL)) {
|
||||
if (ReadFile(m_hPipe, buffer, sizeof(buffer) - 1, &bytesRead, NULL)) {
|
||||
buffer[bytesRead] = '\0';
|
||||
result = godot::String(buffer);
|
||||
result = String(buffer);
|
||||
} else {
|
||||
godot::UtilityFunctions::print("ReadFile from pipe failed, error code: " + godot::String::num_int64(GetLastError()));
|
||||
UtilityFunctions::print("ReadFile from pipe failed, error code: " + String::num_int64(GetLastError()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ScreenPlayGodotWallpaper::connected()
|
||||
{
|
||||
|
||||
// Ensure you have valid appID and type
|
||||
if (m_appID.is_empty()) {
|
||||
UtilityFunctions::print("Unable to connect with empty: appid");
|
||||
emit_signal("disconnected");
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct welcome message and write to the named pipe
|
||||
godot::String welcomeMessage = godot::String("appID=") + m_appID + ",godotWallpaper";
|
||||
|
||||
std::string stdMessage = welcomeMessage.utf8().get_data();
|
||||
DWORD bytesWritten;
|
||||
WriteFile(m_hPipe, stdMessage.c_str(), static_cast<DWORD>(stdMessage.size()), &bytesWritten, NULL);
|
||||
|
||||
if (bytesWritten != stdMessage.size()) {
|
||||
emit_signal("disconnected");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlayGodotWallpaper::messageReceived(const std::string& key, const std::string& value)
|
||||
{
|
||||
try {
|
||||
if (key == "volume") {
|
||||
m_volume = std::stof(value);
|
||||
return;
|
||||
}
|
||||
if (key == "appID") {
|
||||
m_appID = godot::String(value.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (key == "projectPath") {
|
||||
m_projectPath = godot::String(value.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// If none of the keys match
|
||||
// Assuming sceneValueReceived is a signal you've defined
|
||||
emit_signal("sceneValueReceived", key.c_str(), value.c_str());
|
||||
|
||||
} catch (const std::invalid_argument& ia) {
|
||||
// Invalid argument passed to stof/stoi. Handle error as necessary.
|
||||
std::cerr << "Invalid argument: " << ia.what() << std::endl;
|
||||
} catch (const std::out_of_range& oor) {
|
||||
// Converted number is out of range for float/int. Handle error as necessary.
|
||||
std::cerr << "Out of range: " << oor.what() << std::endl;
|
||||
}
|
||||
}
|
||||
void ScreenPlayGodotWallpaper::set_checkWallpaperVisible(bool visible)
|
||||
{
|
||||
m_checkWallpaperVisible = visible;
|
||||
}
|
||||
bool ScreenPlayGodotWallpaper::get_checkWallpaperVisible() const
|
||||
{
|
||||
return m_checkWallpaperVisible;
|
||||
}
|
||||
|
||||
void ScreenPlayGodotWallpaper::set_volume(float vol)
|
||||
{
|
||||
m_volume = vol;
|
||||
}
|
||||
float ScreenPlayGodotWallpaper::get_volume() const
|
||||
{
|
||||
return m_volume;
|
||||
}
|
||||
void ScreenPlayGodotWallpaper::set_appID(const godot::String& id)
|
||||
{
|
||||
m_appID = id;
|
||||
}
|
||||
godot::String ScreenPlayGodotWallpaper::get_appID() const
|
||||
{
|
||||
return m_appID;
|
||||
}
|
||||
void ScreenPlayGodotWallpaper::set_projectPath(const godot::String& path)
|
||||
{
|
||||
m_projectPath = path;
|
||||
}
|
||||
godot::String ScreenPlayGodotWallpaper::get_projectPath() const
|
||||
{
|
||||
return m_projectPath;
|
||||
}
|
||||
void ScreenPlayGodotWallpaper::set_activeScreensList(const godot::PackedInt64Array& screens)
|
||||
{
|
||||
m_activeScreensList = screens;
|
||||
}
|
||||
PackedInt64Array ScreenPlayGodotWallpaper::get_activeScreensList() const
|
||||
{
|
||||
return m_activeScreensList;
|
||||
}
|
||||
|
@ -3,11 +3,14 @@
|
||||
|
||||
#include "godot_cpp/classes/control.hpp"
|
||||
#include "godot_cpp/classes/global_constants.hpp"
|
||||
#include "godot_cpp/classes/timer.hpp"
|
||||
#include "godot_cpp/classes/viewport.hpp"
|
||||
#include "godot_cpp/core/binder_common.hpp"
|
||||
#include "godot_cpp/variant/string.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ScreenPlayGodotWallpaper.h"
|
||||
#include "windowshook.h"
|
||||
@ -20,9 +23,22 @@ public:
|
||||
~ScreenPlayGodotWallpaper() override;
|
||||
|
||||
bool init(int activeScreen);
|
||||
bool create_named_pipe(godot::String pipeName);
|
||||
bool connect_to_named_pipe();
|
||||
godot::String read_from_pipe();
|
||||
void _process(double delta);
|
||||
void messageReceived(const std::string& key, const std::string& value);
|
||||
|
||||
void connected();
|
||||
godot::PackedInt64Array get_activeScreensList() const;
|
||||
void set_activeScreensList(const godot::PackedInt64Array& screens);
|
||||
godot::String get_projectPath() const;
|
||||
void set_projectPath(const godot::String& path);
|
||||
godot::String get_appID() const;
|
||||
void set_appID(const godot::String& id);
|
||||
float get_volume() const;
|
||||
void set_volume(float vol);
|
||||
bool get_checkWallpaperVisible() const;
|
||||
void set_checkWallpaperVisible(bool visible);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@ -36,8 +52,15 @@ private:
|
||||
static int sLastID;
|
||||
|
||||
int mID;
|
||||
godot::String m_appID = "";
|
||||
godot::String m_projectPath = "";
|
||||
std::unique_ptr<WindowsHook> m_hook;
|
||||
HANDLE hPipe;
|
||||
double timesinceLastRead = 0.0;
|
||||
bool isPipeActive = false;
|
||||
HANDLE m_hPipe;
|
||||
double m_timesinceLastRead = 0.0;
|
||||
bool m_isPipeActive = false;
|
||||
|
||||
godot::PackedInt64Array m_activeScreensList;
|
||||
float m_volume = 0.0;
|
||||
bool m_checkWallpaperVisible = false;
|
||||
godot::Timer* m_pingAliveTimer = nullptr;
|
||||
};
|
||||
|
@ -1,55 +1,80 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var screen_play_wallpaper = $ScreenPlayGodotWallpaper
|
||||
@onready var screen_play_wallpaper = $ScreenPlayGodotWallpaper
|
||||
|
||||
var activeScreensList = []
|
||||
var projectPath = ""
|
||||
var appID = ""
|
||||
var volume = 0.0
|
||||
var fillmode = 0
|
||||
var checkWallpaperVisible = false
|
||||
|
||||
func _ready():
|
||||
# "C:\\Code\\cpp\\ScreenPlay\\ScreenPlay\\Content\\wallpaper_godot_fjord\\fjord.zip"
|
||||
var path
|
||||
var args = OS.get_cmdline_args()
|
||||
if( args.size() > 1):
|
||||
parse_args()
|
||||
|
||||
path = "C:\\Code\\cpp\\ScreenPlay\\ScreenPlay\\Content\\wallpaper_godot_fjord\\fjord.zip"
|
||||
var success = ProjectSettings.load_resource_pack (path)
|
||||
func _ready():
|
||||
if not screen_play_wallpaper:
|
||||
printerr("ERROR INVALID SCREENPLAY OBJECT")
|
||||
return
|
||||
|
||||
var path
|
||||
var args = OS.get_cmdline_args()
|
||||
if args.size() > 1:
|
||||
if not parse_args():
|
||||
get_tree().quit()
|
||||
return
|
||||
#screen_play_wallpaper.set_projectPath("C:\\Code\\cpp\\ScreenPlay\\ScreenPlay\\Content\\wallpaper_godot_fjord")
|
||||
path = screen_play_wallpaper.get_projectPath() + "/project.zip"
|
||||
else:
|
||||
get_tree().quit()
|
||||
return
|
||||
print(path)
|
||||
if load_scene(path):
|
||||
var ok = screen_play_wallpaper.init(screen_play_wallpaper.get_activeScreensList()[0])
|
||||
print("init ", ok)
|
||||
Engine.set_max_fps(24)
|
||||
|
||||
func load_scene(path):
|
||||
var success = ProjectSettings.load_resource_pack(path)
|
||||
if success:
|
||||
var scene_resource = load("res://wallpaper.tscn")
|
||||
if scene_resource:
|
||||
var scene_instance = scene_resource.instantiate()
|
||||
add_child(scene_instance)
|
||||
var ok = screen_play_wallpaper.init(0)
|
||||
print("init ", ok)
|
||||
if scene_instance:
|
||||
add_child(scene_instance)
|
||||
else:
|
||||
print("Failed to instantiate the wallpaper.tscn scene.")
|
||||
return false
|
||||
else:
|
||||
print("Failed to load the wallpaper.tscn scene.")
|
||||
return false
|
||||
else:
|
||||
print("Failed to load the PCK file.")
|
||||
Engine.set_max_fps(24)
|
||||
|
||||
return false
|
||||
return true
|
||||
|
||||
func parse_args():
|
||||
var args = OS.get_cmdline_args()
|
||||
print("Parse args:", args)
|
||||
var offset = 0
|
||||
if args[0] == "res://main.tscn":
|
||||
offset = 1
|
||||
|
||||
if args.size() < 7: # Adjust this number based on the expected number of arguments
|
||||
print("Not enough arguments provided!")
|
||||
return
|
||||
return false
|
||||
|
||||
# Parse the arguments based on their expected positions
|
||||
activeScreensList = args[0].split(",")
|
||||
for idx in range(activeScreensList.size()):
|
||||
activeScreensList[idx] = int(activeScreensList[idx])
|
||||
var activeScreensList = []
|
||||
if args[0 + offset].is_valid_int():
|
||||
activeScreensList.append(args[0 + offset].to_int())
|
||||
else:
|
||||
var potentialInts = args[0 + offset].split(",")
|
||||
for val in potentialInts:
|
||||
if not val.is_valid_int():
|
||||
print("Invalid argument: Not an integer:", val)
|
||||
return false
|
||||
else:
|
||||
activeScreensList.append(val.to_int())
|
||||
|
||||
projectPath = args[1]
|
||||
appID = args[2]
|
||||
volume = float(args[3])
|
||||
fillmode = int(args[4])
|
||||
# Assuming 'type' is not a global variable since it's not listed above
|
||||
screen_play_wallpaper.set_projectPath(args[1 + offset])
|
||||
screen_play_wallpaper.set_appID(args[2 + offset].replace("appID=", ""))
|
||||
screen_play_wallpaper.set_volume(float(args[3 + offset]))
|
||||
#screen_play_wallpaper.set_fillmode(int(args[4 + offset]))
|
||||
var type = args[5] # This might need further parsing depending on its expected format
|
||||
checkWallpaperVisible = args[6].to_lower() == "true"
|
||||
screen_play_wallpaper.set_checkWallpaperVisible(args[6 + offset].to_lower() == "true")
|
||||
screen_play_wallpaper.set_activeScreensList(activeScreensList)
|
||||
|
||||
# Print or use the parsed values as needed
|
||||
print(activeScreensList, projectPath, appID, volume, fillmode, type, checkWallpaperVisible)
|
||||
print("Parsing done:", activeScreensList, screen_play_wallpaper.get_projectPath(), screen_play_wallpaper.get_appID(), screen_play_wallpaper.get_volume(), type, screen_play_wallpaper.get_checkWallpaperVisible())
|
||||
return true
|
||||
|
@ -13,6 +13,7 @@ config_version=5
|
||||
config/name="ScreenPlay"
|
||||
run/main_scene="res://main.tscn"
|
||||
config/features=PackedStringArray("4.1", "Mobile")
|
||||
boot_splash/bg_color=Color(0.141176, 0.141176, 0.141176, 0)
|
||||
boot_splash/show_image=false
|
||||
boot_splash/fullsize=false
|
||||
config/icon="res://icon.svg"
|
||||
@ -26,6 +27,10 @@ window/size/initial_position_type=0
|
||||
window/size/initial_position=Vector2i(9999999, 9999999)
|
||||
window/size/borderless=true
|
||||
|
||||
[editor]
|
||||
|
||||
run/main_run_args="\"0\" \"C:/Code/cpp/ScreenPlay/ScreenPlay/Content/wallpaper_godot_fjord\" \"appID=vin6wuDQclPPJmFdouKukfGUKLrVBDCZ\" \"1\" \"Cover\" \"GodotWallpaper\" \"1\""
|
||||
|
||||
[filesystem]
|
||||
|
||||
import/blender/enabled=false
|
||||
|
Loading…
Reference in New Issue
Block a user