-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from TheRyeGuyWhoWillNowDie/ui-and-map-interact…
…-resources Ui and map interact resources
- Loading branch information
Showing
22 changed files
with
618 additions
and
60 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/object.svg-caf74a3db4d189b26740def05330063d.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/opensusinteraction/icons/object.svg" | ||
dest_files=[ "res://.import/object.svg-caf74a3db4d189b26740def05330063d.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
tool | ||
extends EditorPlugin | ||
|
||
#custom resources | ||
var interact_resource_script | ||
var interactmap_resource_script | ||
var interactui_resource_script | ||
|
||
#icons | ||
var object_icon | ||
|
||
func _enter_tree(): | ||
#load custom resources | ||
interact_resource_script = preload("res://addons/opensusinteraction/resources/interact/interact.gd") | ||
interactmap_resource_script = preload("res://addons/opensusinteraction/resources/interactmap/interactmap.gd") | ||
interactui_resource_script = preload("res://addons/opensusinteraction/resources/interactui/interactui.gd") | ||
|
||
#load icons | ||
object_icon = preload("res://addons/opensusinteraction/icons/object.svg") | ||
|
||
#add custom resources | ||
add_custom_type("Interact", "Resource", interact_resource_script, object_icon) | ||
add_custom_type("InteractMap", "Resource", interactmap_resource_script, object_icon) | ||
add_custom_type("InteractUI", "Resource", interactui_resource_script, object_icon) | ||
|
||
|
||
func _exit_tree(): | ||
remove_custom_type("Interact") | ||
remove_custom_type("InteractMap") | ||
remove_custom_type("InteractUI") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[plugin] | ||
|
||
name="OpenSuspect Interaction" | ||
description="A plugin to help manage system interaction in OpenSuspect." | ||
author="TheSecondReal0" | ||
version="1.0.0" | ||
script="opensusinteraction.gd" |
98 changes: 98 additions & 0 deletions
98
src/addons/opensusinteraction/resources/interact/interact.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
tool | ||
extends Resource | ||
|
||
class_name Interact | ||
|
||
enum type {ui = 1, map = 2} | ||
export(type) var interact_type = 1 | ||
|
||
#needed to instance new unique resources in editor | ||
var base_ui_resource: Resource = ResourceLoader.load("res://addons/opensusinteraction/resources/interactui/interactui.tres") | ||
var base_map_resource:Resource = ResourceLoader.load("res://addons/opensusinteraction/resources/interactmap/interactmap.tres") | ||
|
||
#changed in the editor via overriding get(), set(), and get_property_list() | ||
var ui_res: Resource = base_ui_resource.duplicate() | ||
var map_res: Resource = base_map_resource.duplicate() | ||
|
||
var interact_data: Dictionary = {} | ||
|
||
#called to execute the interaction this resource is customized for | ||
func interact(_from: Node): | ||
#print(interact_type) | ||
match interact_type: | ||
type.ui: | ||
ui_res.interact(_from) | ||
type.map: | ||
map_res.interact(_from) | ||
|
||
func get_interact_data(_from: Node = null) -> Dictionary: | ||
var interact_data: Dictionary = {} | ||
var res_interact_data: Dictionary = {} | ||
#print(interact_type) | ||
match interact_type: | ||
type.ui: | ||
res_interact_data = ui_res.get_interact_data(_from) | ||
type.map: | ||
res_interact_data = map_res.get_interact_data(_from) | ||
for i in res_interact_data.keys(): | ||
interact_data[i] = res_interact_data[i] | ||
if not interact_data.keys().has("interact_type"): | ||
interact_data["interact_type"] = interact_type | ||
return interact_data | ||
|
||
func _init(): | ||
#ensures customizing this resource won't change other resources | ||
if Engine.editor_hint: | ||
resource_local_to_scene = true | ||
|
||
#EDITOR STUFF BELOW THIS POINT, DO NOT TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING | ||
#--------------------------------------------------------------------------------------------------- | ||
#overrides set(), allows for export var groups and display properties that don't | ||
#match actual var names | ||
func _set(property, value): | ||
# #add custom stuff to inspector and use this to see what it's trying to do | ||
# #so you can figure out how to handle it | ||
#print("setting ", property, " to ", value) | ||
match property: | ||
"ui_resource": | ||
#if new resource is a ui interact resource | ||
if value is preload("res://addons/opensusinteraction/resources/interactui/interactui.gd"): | ||
ui_res = value | ||
else: | ||
#create new ui interact resource | ||
ui_res = base_ui_resource.duplicate() | ||
"map_resource": | ||
#if new resource is a map interact resource | ||
if value is preload("res://addons/opensusinteraction/resources/interactmap/interactmap.gd"): | ||
map_res = value | ||
else: | ||
#create new map interact resource | ||
map_res = base_map_resource.duplicate() | ||
property_list_changed_notify() | ||
return true | ||
|
||
#overrides get(), allows for export var groups and display properties that don't | ||
#match actual var names | ||
func _get(property): | ||
match property: | ||
"ui_resource": | ||
return ui_res | ||
"map_resource": | ||
return map_res | ||
|
||
#overrides get_property_list(), tells editor to show more vars in inspector | ||
func _get_property_list(): | ||
# #if not Engine.editor_hint: | ||
# # return [] | ||
var property_list: Array = [] | ||
property_list.append({"name": "ui_resource", | ||
"type": TYPE_OBJECT, | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
"hint": PROPERTY_HINT_RESOURCE_TYPE, | ||
}) | ||
property_list.append({"name": "map_resource", | ||
"type": TYPE_OBJECT, | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
"hint": PROPERTY_HINT_RESOURCE_TYPE, | ||
}) | ||
return property_list |
31 changes: 31 additions & 0 deletions
31
src/addons/opensusinteraction/resources/interact/interact.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[gd_resource type="Resource" load_steps=6 format=2] | ||
|
||
[ext_resource path="res://addons/opensusinteraction/resources/interactmap/interactmap.gd" type="Script" id=1] | ||
[ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.gd" type="Script" id=2] | ||
[ext_resource path="res://addons/opensusinteraction/resources/interact/interact.gd" type="Script" id=3] | ||
|
||
[sub_resource type="Resource" id=1] | ||
resource_local_to_scene = true | ||
resource_name = "InteractMap" | ||
script = ExtResource( 1 ) | ||
interact_with = NodePath("") | ||
interact_data = { | ||
|
||
} | ||
|
||
[sub_resource type="Resource" id=2] | ||
resource_local_to_scene = true | ||
script = ExtResource( 2 ) | ||
ui_name = "" | ||
ui_data = { | ||
|
||
} | ||
advanced/reinstance = false | ||
|
||
[resource] | ||
resource_local_to_scene = true | ||
resource_name = "Interact" | ||
script = ExtResource( 3 ) | ||
interact_type = 1 | ||
ui_resource = SubResource( 2 ) | ||
map_resource = SubResource( 1 ) |
68 changes: 68 additions & 0 deletions
68
src/addons/opensusinteraction/resources/interactmap/interactmap.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
tool | ||
extends Resource | ||
|
||
class_name InteractMap | ||
|
||
#name of the UI to open | ||
export(NodePath) var interact_with | ||
|
||
#export(NodePath) | ||
var attached_to: Node | ||
#data to pass to the UI node | ||
export(Dictionary) var interact_data | ||
|
||
var reported_interact_data: Dictionary = {} | ||
|
||
#called to execute the interaction this resource is customized for | ||
func interact(_from: Node): | ||
if attached_to == null and _from != null: | ||
attached_to = _from | ||
if attached_to == null: | ||
push_error("InteractMap resource trying to be used with no defined node") | ||
return | ||
#print("InteractMap attached_to: ", attached_to) | ||
#print(attached_to.get_node(interact_with)) | ||
MapManager.interact_with(attached_to.get_node(interact_with), attached_to, get_interact_data(_from)) | ||
|
||
func get_interact_data(_from: Node = null) -> Dictionary: | ||
if attached_to == null and _from != null: | ||
attached_to = _from | ||
if attached_to == null: | ||
push_error("InteractMap resource trying to be used with no defined node") | ||
for i in interact_data.keys(): | ||
reported_interact_data[i] = interact_data[i] | ||
#map interact type is 2 | ||
reported_interact_data["interact_type"] = 2 | ||
if attached_to != null: | ||
reported_interact_data["interact"] = attached_to.get_node(interact_with) | ||
else: | ||
reported_interact_data["interact"] = null | ||
reported_interact_data["from_node"] = attached_to | ||
return reported_interact_data | ||
|
||
func _init(): | ||
#ensures customizing this resource won't change other resources | ||
if Engine.editor_hint: | ||
#print("init InteractMap") | ||
resource_local_to_scene = true | ||
|
||
#EDITOR STUFF BELOW THIS POINT, DO NOT TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING | ||
#--------------------------------------------------------------------------------------------------- | ||
#overrides set(), allows for export var groups and display properties that don't | ||
#match actual var names | ||
func _set(property, value): | ||
pass | ||
# match property: | ||
|
||
#overrides get(), allows for export var groups and display properties that don't | ||
#match actual var names | ||
func _get(property): | ||
pass | ||
# match property: | ||
|
||
#overrides get_property_list(), tells editor to show more vars in inspector | ||
func _get_property_list(): | ||
#if not Engine.editor_hint: | ||
# return [] | ||
var property_list: Array = [] | ||
return property_list |
12 changes: 12 additions & 0 deletions
12
src/addons/opensusinteraction/resources/interactmap/interactmap.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gd_resource type="Resource" load_steps=2 format=2] | ||
|
||
[ext_resource path="res://addons/opensusinteraction/resources/interactmap/interactmap.gd" type="Script" id=1] | ||
|
||
[resource] | ||
resource_local_to_scene = true | ||
resource_name = "InteractMap" | ||
script = ExtResource( 1 ) | ||
interact_with = NodePath("") | ||
interact_data = { | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
src/addons/opensusinteraction/resources/interactui/interactui.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
tool | ||
extends Resource | ||
|
||
class_name InteractUI | ||
|
||
#name of the UI to open | ||
export(String) var ui_name | ||
#data to pass to the UI node | ||
export(Dictionary) var ui_data | ||
|
||
#changed in the editor via overriding get(), set(), and get_property_list() | ||
#whether or not to delete and recreate the UI node before opening | ||
var reinstance: bool = false | ||
|
||
var interact_data: Dictionary = {} | ||
|
||
#called to execute the interaction this resource is customized for | ||
func interact(_from: Node = null): | ||
UIManager.open_menu(ui_name, get_interact_data(_from), reinstance) | ||
|
||
func get_interact_data(_from: Node = null) -> Dictionary: | ||
var reported_interact_data = interact_data | ||
for i in ui_data.keys(): | ||
reported_interact_data[i] = ui_data[i] | ||
#ui interact type is 1 | ||
reported_interact_data["interact_type"] = 1 | ||
reported_interact_data["interact"] = ui_name | ||
return reported_interact_data | ||
|
||
func _init(): | ||
#ensures customizing this resource won't change other resources | ||
if Engine.editor_hint: | ||
#print("interactUI init") | ||
resource_local_to_scene = true | ||
|
||
#EDITOR STUFF BELOW THIS POINT, DO NOT TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING | ||
#--------------------------------------------------------------------------------------------------- | ||
#overrides set(), allows for export var groups and display properties that don't | ||
#match actual var names | ||
func _set(property, value): | ||
match property: | ||
"advanced/reinstance": | ||
reinstance = value | ||
|
||
#overrides get(), allows for export var groups and display properties that don't | ||
#match actual var names | ||
func _get(property): | ||
match property: | ||
"advanced/reinstance": | ||
return reinstance | ||
|
||
#overrides get_property_list(), tells editor to show more vars in inspector | ||
func _get_property_list(): | ||
#if not Engine.editor_hint: | ||
# return [] | ||
var property_list: Array = [] | ||
property_list.append({"name": "advanced/reinstance", | ||
"type": TYPE_BOOL, | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
"hint": PROPERTY_HINT_NONE, | ||
}) | ||
return property_list |
12 changes: 12 additions & 0 deletions
12
src/addons/opensusinteraction/resources/interactui/interactui.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gd_resource type="Resource" load_steps=2 format=2] | ||
|
||
[ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.gd" type="Script" id=1] | ||
|
||
[resource] | ||
resource_local_to_scene = true | ||
script = ExtResource( 1 ) | ||
ui_name = "" | ||
ui_data = { | ||
|
||
} | ||
advanced/reinstance = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extends Node | ||
|
||
|
||
# Declare member variables here. Examples: | ||
# var a = 2 | ||
# var b = "text" | ||
var mapdata | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
set_network_master(1) | ||
func distribute(): | ||
var map = File.new() | ||
map.open("user://maps/servermap.tscn", File.READ) | ||
if not map.file_exists(): | ||
pass | ||
mapdata = map.get_as_text() | ||
rpc("recieve",mapdata) | ||
recieve(mapdata) | ||
map.close() | ||
remotesync func recieve(data): | ||
var localmap = File.new() | ||
localmap.open("user://maps/currentmap.tscn", File.WRITE) | ||
localmap.store_string(data) | ||
localmap.close() | ||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass |
Oops, something went wrong.