Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
leanmendoza committed Jan 9, 2025
1 parent 32f8ce4 commit edd12bc
Show file tree
Hide file tree
Showing 17 changed files with 277 additions and 104 deletions.
5 changes: 5 additions & 0 deletions godot/src/global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ func _ready():

self.avatars = AvatarScene.new()
self.avatars.set_name("avatar_scene")

self.web_http_requester.set_tls_options(TLSOptions.client())


get_tree().root.add_child.call_deferred(self.tokio_runtime)
get_tree().root.add_child.call_deferred(self.web_http_requester)
get_tree().root.add_child.call_deferred(self.music_player)
get_tree().root.add_child.call_deferred(self.scene_fetcher)
get_tree().root.add_child.call_deferred(self.content_provider)
Expand Down
2 changes: 2 additions & 0 deletions godot/src/logic/realm.gd
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ func async_set_realm(new_realm_string: String, search_new_pos: bool = false) ->
realm_string = new_realm_string
realm_url = Realm.ensure_ends_with_slash(Realm.resolve_realm_url(realm_string))
realm_url = Realm.ensure_starts_with_https(realm_url)

print("async_set_realm")

var promise: Promise = Global.http_requester.request_json(
realm_url + "about", HTTPClient.METHOD_GET, "", {}
Expand Down
22 changes: 15 additions & 7 deletions godot/src/ui/components/auth/lobby.gd
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func async_close_sign_in(generate_snapshots: bool = true):

# gdlint:ignore = async-function-name
func _ready():
print("testing logggg")
var android_login = %AndroidLogin
if is_instance_valid(android_login) and android_login.is_platform_supported():
android_login.set_lobby(self)
Expand All @@ -93,26 +94,28 @@ func _ready():
Global.scene_runner.set_pause(true)

var args = OS.get_cmdline_args()
if args.has("--skip-lobby"):
_skip_lobby = true
#if args.has("--skip-lobby"):
_skip_lobby = true

print("Before trying to recover")
var session_account: Dictionary = Global.get_config().session_account

if Global.player_identity.try_recover_account(session_account):
loading_first_profile = true
show_panel(control_loading)
elif _skip_lobby:
if _skip_lobby:
print("Miowemfwioemfiweofm")
show_panel(control_loading)
create_guest_account_if_needed()
print("calling the call deferred")
go_to_explorer.call_deferred()
else:
show_panel(control_start)


func go_to_explorer():
if is_inside_tree():
print("changing to explorer")
get_tree().change_scene_to_file("res://src/ui/explorer.tscn")

else:
print("not inside the treee!!!")

func _async_on_profile_changed(new_profile: DclUserProfile):
current_profile = new_profile
Expand Down Expand Up @@ -235,10 +238,15 @@ func _on_button_cancel_pressed():

func create_guest_account_if_needed():
if not guest_account_created:
print("AAAAA")
Global.get_config().guest_profile = {}
print("BBBBBB")
Global.get_config().save_to_settings_file()
print("CCCCCC")
Global.player_identity.create_guest_account()
print("DDDDDD")
Global.player_identity.set_default_profile()
print("EEEEEE")
guest_account_created = true


Expand Down
1 change: 1 addition & 0 deletions godot/src/ui/components/backpack/backpack.gd
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func _ready():
wearable_data[wearable_id] = wearable
if wearable == null:
printerr("Error loading wearable_id ", wearable_id)
print(wearable)

_update_visible_categories()

Expand Down
10 changes: 5 additions & 5 deletions godot/src/ui/components/map_shader/map.gdshader
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ uniform float line_width_px = 1.0;
uniform vec2 selected_tile = vec2(20.0, 20.0);

const vec3[] colors = {
vec3(0.0, 0.0, 0.0), // without
vec3(0.0, 0.0, 0.0), // without
vec3(0.314,0.329,0.831), // district
vec3(0.439,0.675,0.463), // plaza
vec3(0.443,0.424,0.478), // road
Expand All @@ -29,14 +29,14 @@ void fragment() {
vec2 frag_position = floor(world_position);
float fx = frag_position.x / size, fy = (frag_position.y / size) + 1.0;
float cx = floor(fx), cy = floor(fy);

vec4 pixel_data = texelFetch(map_data, ivec2(int(cx), int(cy)), 0);
int flagsR = int(pixel_data.r * 255.0);
int flagsG = int(pixel_data.g * 255.0);

bool topMask = (flagsR & 0x8) > 0;
bool leftMask = (flagsR & 0x10) > 0;

vec3 parcel_color;
if (flagsG == 32) {
parcel_color = colors[1];
Expand Down Expand Up @@ -75,10 +75,10 @@ void fragment() {
if (borderTop && (fy - cy < line_width)) {
resolved_color = vec4(0.0, 0.0, 0.0, COLOR.a);
}

if (selected_tile.x == cx && selected_tile.y == cy) {
resolved_color += vec4(0.7, 0.1, 0.1, COLOR.a);
}

COLOR = resolved_color;
}
4 changes: 3 additions & 1 deletion lib/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ rustflags = [
]

[build]
target = "wasm32-unknown-unknown"
target = "wasm32-unknown-emscripten"
toolchain = "nightly"

5 changes: 4 additions & 1 deletion lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ chrono = "0.4.31"

simple-easing = "1.0.1"

url = "2"
lazy_static = "1"
sharded-slab = "0.1.1"

multihash-codetable = { version = "0.1.1", features = ["digest", "sha2"] }
cid = "0.11.0"
multipart = { version = "0.18.0", default-features = false, features = ["client", "lazy_static"] }
Expand All @@ -75,7 +79,7 @@ jni = { version = "0.21.1", features = ["invocation"] }
paranoid-android = "0.2.1"

[features]
default = ["use_ffmpeg", "use_livekit", "use_deno", "enable_inspector"]
default = []
use_ffmpeg = ["dep:ffmpeg-next", "dep:cpal"]
use_livekit = ["dep:livekit"]
use_deno = ["dep:deno_core", "dep:v8"]
Expand Down
15 changes: 5 additions & 10 deletions lib/src/content/content_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ use crate::godot_classes::dcl_resource_tracker::{
report_resource_start,
};

#[cfg(not(target_arch = "wasm32"))]
use super::resource_provider::ResourceProvider;
#[cfg(target_arch = "wasm32")]
use super::web_resource_provider::ResourceProvider;

use super::{
audio::load_audio,
gltf::{
Expand All @@ -47,8 +52,6 @@ use super::{
video::download_video,
wearable_entities::{request_wearables, WearableManyResolved},
};
#[cfg(not(target_arch = "wasm32"))]
use super::resource_provider::ResourceProvider;

#[cfg(feature = "use_resource_tracking")]
use super::resource_download_tracking::ResourceDownloadTracking;
Expand All @@ -63,7 +66,6 @@ pub struct ContentEntry {
#[class(base=Node)]
pub struct ContentProvider {
content_folder: Arc<String>,
#[cfg(not(target_arch = "wasm32"))]
resource_provider: Arc<ResourceProvider>,
#[cfg(feature = "use_resource_tracking")]
resource_download_tracking: Arc<ResourceDownloadTracking>,
Expand All @@ -82,7 +84,6 @@ pub struct ContentProvider {
#[derive(Clone)]
pub struct ContentProviderContext {
pub content_folder: Arc<String>,
#[cfg(not(target_arch = "wasm32"))]
pub resource_provider: Arc<ResourceProvider>,
pub http_queue_requester: Arc<HttpQueueRequester>,
pub godot_single_thread: Arc<Semaphore>,
Expand All @@ -103,7 +104,6 @@ impl INode for ContentProvider {
let resource_download_tracking = Arc::new(ResourceDownloadTracking::new());

Self {
#[cfg(not(target_arch = "wasm32"))]
resource_provider: Arc::new(ResourceProvider::new(
content_folder.clone().as_str(),
2048 * 1000 * 1000,
Expand Down Expand Up @@ -424,7 +424,6 @@ impl ContentProvider {

#[func]
pub fn fetch_file_by_url(&mut self, file_hash: GString, url: GString) -> Gd<Promise> {

let file_hash = file_hash.to_string();

let url = url.to_string();
Expand All @@ -435,7 +434,6 @@ impl ContentProvider {
let loaded_resources = self.loaded_resources.clone();
let hash_id = file_hash.clone();


#[cfg(not(target_arch = "wasm32"))]
{
TokioRuntime::spawn(async move {
Expand Down Expand Up @@ -479,7 +477,6 @@ impl ContentProvider {

let bytes = bytes.to_vec();


#[cfg(not(target_arch = "wasm32"))]
{
TokioRuntime::spawn(async move {
Expand Down Expand Up @@ -970,7 +967,6 @@ impl ContentProvider {

#[func]
pub fn set_cache_folder_max_size(&mut self, size: i64) {

#[cfg(not(target_arch = "wasm32"))]
self.resource_provider.set_max_cache_size(size)
}
Expand Down Expand Up @@ -1059,7 +1055,6 @@ impl ContentProvider {
ContentProviderContext {
content_folder: self.content_folder.clone(),
http_queue_requester: self.http_queue_requester.clone(),
#[cfg(not(target_arch = "wasm32"))]
resource_provider: self.resource_provider.clone(),
godot_single_thread: self.godot_single_thread.clone(),
texture_quality: self.texture_quality.clone(),
Expand Down
3 changes: 3 additions & 0 deletions lib/src/content/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ mod profile;
mod resource_download_tracking;
#[cfg(not(target_arch = "wasm32"))]
mod resource_provider;
#[cfg(target_arch = "wasm32")]
mod web_resource_provider;
pub mod semaphore_ext;
mod texture;
mod thread_safety;
mod video;
mod wearable_entities;

41 changes: 40 additions & 1 deletion lib/src/godot_classes/dcl_global.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
use std::sync::Arc;
use std::collections::VecDeque;
use std::collections::HashMap;

use godot::{
engine::{node::ProcessMode, Engine},
prelude::*,
};
use utilities::print;

use crate::http_request::request_response::RequestOption;
use crate::http_request::request_response::RequestResponse;
use crate::http_request::request_response::RequestResponseError;
use crate::http_request::web_http_requester::DclWebHttpRequester;
use crate::{
analytics::metrics::Metrics,
auth::{dcl_player_identity::DclPlayerIdentity, ethereum_provider::EthereumProvider},
avatars::avatar_scene::AvatarScene,
comms::communication_manager::CommunicationManager,
content::content_provider::ContentProvider,
dcl::common::set_scene_log_enabled,
http_request::rust_http_queue_requester::RustHttpQueueRequester,
http_request::{http_queue_requester::QueueRequest, rust_http_queue_requester::RustHttpQueueRequester},
scene_runner::{scene_manager::SceneManager, tokio_runtime::TokioRuntime},
test_runner::testing_tools::DclTestingTools,
tools::network_inspector::{NetworkInspector, NetworkInspectorSender},
Expand All @@ -23,6 +30,9 @@ use super::{
portables::DclPortableExperienceController,
};

use godot::engine::HttpClient;
use godot::obj::bounds::*;

#[cfg(target_os = "android")]
mod android {
use tracing_subscriber::filter::LevelFilter;
Expand All @@ -40,6 +50,25 @@ mod android {
}
}

#[cfg(target_arch = "wasm32")]
mod wasm {
use tracing_subscriber::prelude::*;
use tracing_subscriber::{self, registry};

pub fn init_logger() {
let wasm_layer =
tracing_subscriber::fmt::Layer::new()
.event_format(
tracing_subscriber::fmt::format::Format::default()
.with_level(false).without_time()
)
.with_writer(crate::utils::log_writer::GodotWasmLogMakeWriter::new("wasm".to_string()));

registry().with(wasm_layer).init();
}
}


#[derive(GodotClass)]
#[class(base=Node)]
pub struct DclGlobal {
Expand Down Expand Up @@ -83,12 +112,16 @@ pub struct DclGlobal {
pub renderer_version: GString,

pub is_mobile: bool,
pub is_wasm: bool,

#[var]
pub has_javascript_debugger: bool,

#[var]
pub network_inspector: Gd<NetworkInspector>,

#[var]
pub web_http_requester: Gd<DclWebHttpRequester>,
}

#[godot_api]
Expand All @@ -97,6 +130,9 @@ impl INode for DclGlobal {
#[cfg(target_os = "android")]
android::init_logger();

#[cfg(target_arch = "wasm32")]
wasm::init_logger();

#[cfg(not(target_os = "android"))]
let _ = tracing_subscriber::fmt::try_init();

Expand Down Expand Up @@ -130,6 +166,7 @@ impl INode for DclGlobal {
Self {
_base: base,
is_mobile: godot::engine::Os::singleton().has_feature("mobile".into()),
is_wasm: godot::engine::Os::singleton().has_feature("wasm".into()),
scene_runner,
comms,
avatars,
Expand All @@ -153,6 +190,8 @@ impl INode for DclGlobal {
has_javascript_debugger: true,
#[cfg(not(feature = "enable_inspector"))]
has_javascript_debugger: false,

web_http_requester: DclWebHttpRequester::new_alloc(),
}
}
}
Expand Down
Loading

0 comments on commit edd12bc

Please sign in to comment.