mirror of
https://github.com/Relintai/uml_generator.git
synced 2024-11-12 10:25:12 +01:00
Implement super simple uml generation.
This commit is contained in:
parent
a2f2fbedca
commit
e006794655
4
project/BaseClassControl.gd
Normal file
4
project/BaseClassControl.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends VBoxContainer
|
||||
|
||||
func set_base_class_name(text):
|
||||
$Container/PanelContainer/Label.text = text
|
54
project/BaseClassControl.tscn
Normal file
54
project/BaseClassControl.tscn
Normal file
@ -0,0 +1,54 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://BaseClassControl.gd" type="Script" id=1]
|
||||
[ext_resource path="res://inherits.png" type="Texture" id=2]
|
||||
[ext_resource path="res://line.png" type="Texture" id=3]
|
||||
|
||||
[node name="BaseClassControl" type="VBoxContainer"]
|
||||
margin_right = 51.0
|
||||
margin_bottom = 62.0
|
||||
custom_constants/separation = 0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Container" type="CenterContainer" parent="."]
|
||||
margin_right = 57.0
|
||||
margin_bottom = 28.0
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Container"]
|
||||
margin_right = 57.0
|
||||
margin_bottom = 28.0
|
||||
|
||||
[node name="Label" type="Label" parent="Container/PanelContainer"]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 21.0
|
||||
text = "Object"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
margin_top = 28.0
|
||||
margin_right = 57.0
|
||||
margin_bottom = 54.0
|
||||
alignment = 1
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
|
||||
margin_left = 19.0
|
||||
margin_right = 38.0
|
||||
margin_bottom = 26.0
|
||||
custom_constants/separation = 0
|
||||
alignment = 1
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/VBoxContainer"]
|
||||
margin_right = 19.0
|
||||
margin_bottom = 16.0
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="HBoxContainer/VBoxContainer"]
|
||||
margin_top = 16.0
|
||||
margin_right = 19.0
|
||||
margin_bottom = 26.0
|
||||
rect_min_size = Vector2( 0, 10 )
|
||||
texture = ExtResource( 3 )
|
||||
expand = true
|
14
project/ClassControl.gd
Normal file
14
project/ClassControl.gd
Normal file
@ -0,0 +1,14 @@
|
||||
extends PanelContainer
|
||||
|
||||
func set_class_name(n):
|
||||
$VBoxContainer/HBoxContainer/ClassName.text = n
|
||||
|
||||
|
||||
func add_h_separator():
|
||||
var hsep : HSeparator = HSeparator.new()
|
||||
$VBoxContainer.add_child(hsep)
|
||||
|
||||
func add_line(line : String):
|
||||
var l : Label = Label.new()
|
||||
l.text = line
|
||||
$VBoxContainer.add_child(l)
|
36
project/ClassControl.tscn
Normal file
36
project/ClassControl.tscn
Normal file
@ -0,0 +1,36 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://ClassControl.gd" type="Script" id=1]
|
||||
|
||||
[node name="ClassControl" type="PanelContainer"]
|
||||
margin_right = 42.0
|
||||
margin_bottom = 30.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 41.0
|
||||
margin_bottom = 37.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_right = 34.0
|
||||
margin_bottom = 14.0
|
||||
alignment = 1
|
||||
|
||||
[node name="ClassName" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_right = 34.0
|
||||
margin_bottom = 14.0
|
||||
text = "Node"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
|
||||
margin_top = 18.0
|
||||
margin_right = 34.0
|
||||
margin_bottom = 22.0
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer"]
|
||||
margin_top = 26.0
|
||||
margin_right = 34.0
|
||||
margin_bottom = 30.0
|
168
project/UMLGenerator.gd
Normal file
168
project/UMLGenerator.gd
Normal file
@ -0,0 +1,168 @@
|
||||
extends Control
|
||||
|
||||
var BaseClassControl = preload("res://BaseClassControl.tscn")
|
||||
var ClassControl = preload("res://ClassControl.tscn")
|
||||
|
||||
export(NodePath) var content_container_path : NodePath
|
||||
|
||||
enum States {
|
||||
STATE_NEXT = 0,
|
||||
STATE_RESIZE_WINDOW,
|
||||
STATE_TAKE_SCREENSHOT
|
||||
};
|
||||
|
||||
enum AccessModifierState {
|
||||
ACCESS_MODIFIER_PRIVATE = 0,
|
||||
ACCESS_MODIFIER_PROTECTED,
|
||||
ACCESS_MODIFIER_PUBLIC
|
||||
};
|
||||
|
||||
var _content_container : Control
|
||||
var _files : PoolStringArray
|
||||
var _error_files : PoolStringArray
|
||||
var _current_index : int = 0
|
||||
var _current_state = 0
|
||||
|
||||
func _ready():
|
||||
var dir : Directory = Directory.new()
|
||||
|
||||
if !dir.dir_exists("res://data/"):
|
||||
print("Error: Directory res://data/ Does not exists!")
|
||||
return
|
||||
|
||||
if !dir.dir_exists("res://output/"):
|
||||
print("Error: Directory res://output/ exists!")
|
||||
return
|
||||
|
||||
dir.make_dir("res://output/")
|
||||
|
||||
if dir.open("res://data/") == OK:
|
||||
dir.list_dir_begin()
|
||||
var file_name = dir.get_next()
|
||||
while file_name != "":
|
||||
if !dir.current_is_dir():
|
||||
_files.push_back(file_name)
|
||||
|
||||
file_name = dir.get_next()
|
||||
else:
|
||||
print("An error occurred when trying to access res://data/.")
|
||||
|
||||
_content_container = get_node(content_container_path)
|
||||
|
||||
func _process(delta):
|
||||
if _current_state == States.STATE_NEXT:
|
||||
_process_state_next(delta)
|
||||
elif _current_state == States.STATE_RESIZE_WINDOW:
|
||||
_process_state_resize_window(delta)
|
||||
elif _current_state == States.STATE_TAKE_SCREENSHOT:
|
||||
_process_state_take_screenshot(delta)
|
||||
|
||||
func _process_state_next(delta):
|
||||
if _current_index == _files.size():
|
||||
print("Done!")
|
||||
|
||||
if _error_files.size() > 0:
|
||||
print("Errors happened in files:")
|
||||
print(_error_files)
|
||||
else:
|
||||
print("Generatin successful!")
|
||||
|
||||
get_tree().quit()
|
||||
return
|
||||
|
||||
var fn : String = "res://data/" + _files[_current_index]
|
||||
|
||||
var file : File = File.new()
|
||||
file.open(fn, File.READ)
|
||||
var content : String = file.get_as_text()
|
||||
file.close()
|
||||
|
||||
clear_content()
|
||||
|
||||
content = content.replace("\r\n", "\n")
|
||||
var lines : Array = content.split("\n")
|
||||
|
||||
var in_class : bool = false
|
||||
var current_class_access_modifier : int = AccessModifierState.ACCESS_MODIFIER_PRIVATE
|
||||
var class_control : Control = null
|
||||
|
||||
for i in range(lines.size()):
|
||||
var l : String = lines[i]
|
||||
l = l.strip_edges()
|
||||
|
||||
if l == "":
|
||||
continue
|
||||
|
||||
if l[0] == "#":
|
||||
continue
|
||||
|
||||
if l.begins_with("base_class "):
|
||||
var base_class : String = l.trim_prefix("base_class ")
|
||||
|
||||
var bcc = BaseClassControl.instance()
|
||||
bcc.set_base_class_name(base_class)
|
||||
|
||||
_content_container.add_child(bcc)
|
||||
continue
|
||||
|
||||
if l.begins_with("class "):
|
||||
in_class = true
|
||||
current_class_access_modifier = AccessModifierState.ACCESS_MODIFIER_PRIVATE
|
||||
class_control = ClassControl.instance()
|
||||
class_control.set_class_name(l.trim_prefix("class "))
|
||||
_content_container.add_child(class_control)
|
||||
continue
|
||||
|
||||
if l.begins_with("struct "):
|
||||
in_class = true
|
||||
current_class_access_modifier = AccessModifierState.ACCESS_MODIFIER_PUBLIC
|
||||
class_control = ClassControl.instance()
|
||||
class_control.set_class_name(l.trim_prefix("struct "))
|
||||
_content_container.add_child(class_control)
|
||||
continue
|
||||
|
||||
if l.begins_with("public:"):
|
||||
current_class_access_modifier = AccessModifierState.ACCESS_MODIFIER_PUBLIC
|
||||
continue
|
||||
|
||||
if l.begins_with("protected:"):
|
||||
current_class_access_modifier = AccessModifierState.ACCESS_MODIFIER_PROTECTED
|
||||
continue
|
||||
|
||||
if l.begins_with("private:"):
|
||||
current_class_access_modifier = AccessModifierState.ACCESS_MODIFIER_PRIVATE
|
||||
continue
|
||||
|
||||
if l.begins_with("--"):
|
||||
class_control.add_h_separator()
|
||||
continue
|
||||
|
||||
# At this point everything should'have been handled except methods and variables
|
||||
|
||||
l = l.replace(";", "")
|
||||
|
||||
if current_class_access_modifier == AccessModifierState.ACCESS_MODIFIER_PUBLIC:
|
||||
l = "+ " + l
|
||||
elif current_class_access_modifier == AccessModifierState.ACCESS_MODIFIER_PROTECTED:
|
||||
l = "# " + l
|
||||
elif current_class_access_modifier == AccessModifierState.ACCESS_MODIFIER_PRIVATE:
|
||||
l = "- " + l
|
||||
|
||||
class_control.add_line(l)
|
||||
|
||||
_current_state = States.STATE_RESIZE_WINDOW
|
||||
|
||||
func _process_state_resize_window(delta):
|
||||
pass
|
||||
#_current_state = States.STATE_TAKE_SCREENSHOT
|
||||
|
||||
|
||||
func _process_state_take_screenshot(delta):
|
||||
|
||||
_current_index += 1
|
||||
_current_state = States.STATE_NEXT
|
||||
|
||||
func clear_content():
|
||||
for c in _content_container.get_children():
|
||||
c.queue_free()
|
||||
_content_container.remove_child(c)
|
@ -1,5 +1,19 @@
|
||||
[gd_scene format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[node name="UMLGen" type="Control"]
|
||||
[ext_resource path="res://UMLGenerator.gd" type="Script" id=1]
|
||||
[ext_resource path="res://new_theme.tres" type="Theme" id=4]
|
||||
|
||||
[node name="UMLGen" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 4 )
|
||||
script = ExtResource( 1 )
|
||||
content_container_path = NodePath("ScrollContainer/Content")
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="ScrollContainer"]
|
||||
custom_constants/separation = 0
|
||||
alignment = 1
|
||||
|
60
project/data/directory.umlg
Normal file
60
project/data/directory.umlg
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
base_class Object
|
||||
base_class Reference
|
||||
class Directory
|
||||
|
||||
public:
|
||||
Error open_dir(const String &path, bool skip_specials = true);
|
||||
Error open_dir(const char *path, bool skip_specials = true);
|
||||
void close_dir();
|
||||
|
||||
--
|
||||
|
||||
bool has_next();
|
||||
bool read();
|
||||
bool next();
|
||||
|
||||
--
|
||||
|
||||
bool current_is_ok();
|
||||
String current_get_name();
|
||||
String current_get_path();
|
||||
String current_get_extension();
|
||||
const char *current_get_name_cstr();
|
||||
const char *current_get_path_cstr();
|
||||
const char *current_get_extension_cstr();
|
||||
bool current_is_file();
|
||||
bool current_is_dir();
|
||||
bool current_is_special_dir();
|
||||
|
||||
--
|
||||
|
||||
String read_file(const String &path);
|
||||
Error read_file_into(const String &path, String *str);
|
||||
Vector<uint8_t> read_file_bin(const String &path);
|
||||
Error read_file_into_bin(const String &path, Vector<uint8_t> *data);
|
||||
|
||||
--
|
||||
|
||||
Error write_file(const String &path, const String &str);
|
||||
Error write_file_bin(const String &path, const Vector<uint8_t> &data);
|
||||
|
||||
--
|
||||
|
||||
bool is_dir_open();
|
||||
bool is_dir_closed();
|
||||
|
||||
--
|
||||
|
||||
Directory();
|
||||
virtual ~Directory();
|
||||
|
||||
--
|
||||
|
||||
private:
|
||||
bool _skip_specials;
|
||||
int _read_file_result;
|
||||
tinydir_dir _dir;
|
||||
tinydir_file _file;
|
||||
|
||||
bool _dir_open;
|
231
project/data/string.umlg
Normal file
231
project/data/string.umlg
Normal file
@ -0,0 +1,231 @@
|
||||
|
||||
class String
|
||||
public:
|
||||
void push_back(const char element);
|
||||
void push_back(const wchar_t element);
|
||||
void pop_back();
|
||||
void remove(const int index);
|
||||
void erase(const char element);
|
||||
void erase(const int start_index, const int length);
|
||||
void clear();
|
||||
bool empty() const;
|
||||
char get(const int index);
|
||||
const char get(const int index) const;
|
||||
void set(const int index, const char value);
|
||||
|
||||
--
|
||||
|
||||
int size() const;
|
||||
int capacity() const;
|
||||
void ensure_capacity(const int capacity);
|
||||
void resize(const int s);
|
||||
int find(const char val, const int from = 0) const;
|
||||
int find(const String &val, const int from = 0) const;
|
||||
int find_reversed(const char val, const int from = -1) const;
|
||||
int find_reversed(const String &val, const int from = -1) const;
|
||||
void get_substr(char *into_buf, const int start_index, const int len);
|
||||
void get_substr_nt(char *into_buf, const int start_index, const int len);
|
||||
String substr(const int start_index, const int len) const;
|
||||
String substr_index(const int start_index, const int end_index) const;
|
||||
bool contains(const char val) const;
|
||||
bool contains(const String &val) const;
|
||||
--
|
||||
bool is_word_at(const int index, const char *str) const;
|
||||
bool is_word_at(const int index, const String &val) const;
|
||||
--
|
||||
void replace_from(const int start_index, const int length, const String &with);
|
||||
void replace(const String &find_str, const String &with);
|
||||
void replace(const String &find_str, const String &with, const int count);
|
||||
--
|
||||
int compare(const String &other) const;
|
||||
--
|
||||
int first_difference_index(const String &other) const;
|
||||
--
|
||||
void to_lower();
|
||||
String as_lower() const;
|
||||
--
|
||||
void trim();
|
||||
void trim_beginning();
|
||||
void trim_end();
|
||||
--
|
||||
bool ends_with(const char c) const;
|
||||
bool ends_with(const String &str) const;
|
||||
--
|
||||
bool starts_with(const char c) const;
|
||||
bool starts_with(const String &str) const;
|
||||
--
|
||||
int get_slice_count(const char splitter) const;
|
||||
int get_slice_count(const String &splitter) const;
|
||||
String get_slice(const char splitter, int index);
|
||||
String get_slice(const String &splitter, int index);
|
||||
--
|
||||
Vector<String> split(const char splitter) const;
|
||||
Vector<String> split(const String &splitter) const;
|
||||
--
|
||||
uint8_t read_uint8_bytes_at(int &index, bool advance_index = true);
|
||||
uint16_t read_uint16_bytes_at(int &index, bool advance_index = true);
|
||||
uint32_t read_uint32_bytes_at(int &index, bool advance_index = true);
|
||||
uint64_t read_uint64_bytes_at(int &index, bool advance_index = true);
|
||||
--
|
||||
int8_t read_int8_bytes_at(int &index, bool advance_index = true);
|
||||
int16_t read_int16_bytes_at(int &index, bool advance_index = true);
|
||||
int32_t read_int32_bytes_at(int &index, bool advance_index = true);
|
||||
int64_t read_int64_bytes_at(int &index, bool advance_index = true);
|
||||
--
|
||||
void append_uint8_bytes(const uint8_t val);
|
||||
void append_uint16_bytes(const uint16_t val);
|
||||
void append_uint32_bytes(const uint32_t val);
|
||||
void append_uint64_bytes(const uint64_t val);
|
||||
--
|
||||
void append_int8_bytes(const int8_t val);
|
||||
void append_int16_bytes(const int16_t val);
|
||||
void append_int32_bytes(const int32_t val);
|
||||
void append_int64_bytes(const int64_t val);
|
||||
--
|
||||
float read_float_bytes_at(int &index, bool advance_index = true);
|
||||
void append_float_bytes(const float val);
|
||||
double read_double_bytes_at(int &index, bool advance_index = true);
|
||||
void append_double_bytes(const double val);
|
||||
--
|
||||
void append_str(const char *str);
|
||||
void append_str(const wchar_t *str);
|
||||
void append_str(const String &other);
|
||||
void append_str(const std::string &str);
|
||||
void append_str(const String &other, const int from);
|
||||
void append_str(const std::string &str, const int from);
|
||||
--
|
||||
void append_repeat(const char *str, const int times);
|
||||
void append_repeat(const String &other, const int times);
|
||||
--
|
||||
void append_path(const char *path);
|
||||
void append_path(const String &path);
|
||||
void path_clean_end_slash();
|
||||
void path_ensure_end_slash();
|
||||
String path_get_basename() const;
|
||||
String path_get_last_segment() const;
|
||||
String path_get_prev_dir() const;
|
||||
String file_get_extension() const;
|
||||
--
|
||||
void to_html_special_chars();
|
||||
void from_html_special_chars();
|
||||
void newline_to_br();
|
||||
--
|
||||
bool to_bool() const;
|
||||
float to_float() const;
|
||||
double to_double() const;
|
||||
int to_int() const;
|
||||
--
|
||||
bool is_bool() const;
|
||||
bool is_numeric() const;
|
||||
bool is_int() const;
|
||||
bool is_uint() const;
|
||||
bool is_zero() const;
|
||||
--
|
||||
uint32_t to_uint() const;
|
||||
std::string to_string() const;
|
||||
void print() const;
|
||||
--
|
||||
void append(const char *str);
|
||||
void append(const wchar_t *str);
|
||||
void append(const String &other);
|
||||
void append(const std::string &str);
|
||||
void append(const char chr);
|
||||
void append(const wchar_t chr);
|
||||
void append(const int num);
|
||||
void append(const unsigned int num);
|
||||
void append(const float num);
|
||||
void append(const double num);
|
||||
void append(const Variant &variant);
|
||||
--
|
||||
static String bool_num(bool val);
|
||||
static String bool_str(bool val);
|
||||
--
|
||||
static String num(double p_num, int p_decimals = -1);
|
||||
static String num_scientific(double p_num);
|
||||
static String num_real(double p_num, bool p_trailing = true);
|
||||
static String num_int64(int64_t p_num, int base = 10, bool capitalize_hex = false);
|
||||
static String num_uint64(uint64_t p_num, int base = 10, bool capitalize_hex = false);
|
||||
static String chr(char32_t p_char);
|
||||
--
|
||||
String ascii(bool p_allow_extended = false) const;
|
||||
String utf8() const;
|
||||
bool parse_utf8(const char *p_utf8, int p_len = -1); // return true on error
|
||||
static String utf8(const char *p_utf8, int p_len = -1);
|
||||
--
|
||||
static uint32_t hash(const wchar_t *p_cstr, int p_len); /* hash the string */
|
||||
static uint32_t hash(const wchar_t *p_cstr); /* hash the string */
|
||||
static uint32_t hash(const char *p_cstr, int p_len); /* hash the string */
|
||||
static uint32_t hash(const char *p_cstr); /* hash the string */
|
||||
uint32_t hash() const; /* hash the string */
|
||||
uint64_t hash64() const; /* hash the string */
|
||||
--
|
||||
char *c_str();
|
||||
const char *c_str() const;
|
||||
--
|
||||
char *dataw();
|
||||
const char *data() const;
|
||||
--
|
||||
const char operator[](const int index) const;
|
||||
char &operator[](const int index);
|
||||
--
|
||||
String &operator+=(const String &b);
|
||||
String &operator+=(const char chr);
|
||||
String &operator+=(const char *p_c_str);
|
||||
String &operator+=(const std::string &b);
|
||||
--
|
||||
friend String operator+(String lhs, const String &rhs);
|
||||
friend String operator+(String lhs, const char *rhs);
|
||||
friend String operator+(String lhs, const char rhs);
|
||||
friend String operator+(String lhs, const std::string &rhs);
|
||||
--
|
||||
friend bool operator==(const String &a, const String &b);
|
||||
friend bool operator!=(const String &a, const String &b);
|
||||
--
|
||||
friend bool operator==(const String &a, const char *b);
|
||||
friend bool operator!=(const String &a, const char *b);
|
||||
--
|
||||
friend bool operator==(const char *b, const String &a);
|
||||
friend bool operator!=(const char *b, const String &a);
|
||||
--
|
||||
friend bool operator==(const String &a, const wchar_t *b);
|
||||
friend bool operator!=(const String &a, const wchar_t *b);
|
||||
--
|
||||
friend bool operator==(const wchar_t *b, const String &a);
|
||||
friend bool operator!=(const wchar_t *b, const String &a);
|
||||
--
|
||||
friend bool operator==(const String &a, std::string &b);
|
||||
friend bool operator!=(const String &a, std::string &b);
|
||||
--
|
||||
friend bool operator==(std::string &b, const String &a);
|
||||
friend bool operator!=(std::string &b, const String &a);
|
||||
--
|
||||
friend bool operator<(const String &a, const String &b);
|
||||
friend bool operator>(const String &a, const String &b);
|
||||
friend bool operator<=(const String &a, const String &b);
|
||||
friend bool operator>=(const String &a, const String &b);
|
||||
--
|
||||
operator std::string() { return to_string(); }
|
||||
operator std::string() const { return to_string(); }
|
||||
--
|
||||
String &operator=(const String &other);
|
||||
String &operator=(const std::string &other);
|
||||
String &operator=(const char *other);
|
||||
String &operator=(const wchar_t *other);
|
||||
--
|
||||
String();
|
||||
String(const String &other);
|
||||
String(const String &other, const int grow_by);
|
||||
String(const char *p_c_str);
|
||||
String(const char *p_c_str, const int grow_by);
|
||||
String(const wchar_t *p_c_str);
|
||||
String(const int prealloc);
|
||||
String(const int prealloc, const int grow_by);
|
||||
String(const std::string &str);
|
||||
~String();
|
||||
--
|
||||
private:
|
||||
char *_data;
|
||||
int _actual_size;
|
||||
int _size;
|
||||
int _grow_by;
|
||||
|
46
project/examples/directory.umlg
Normal file
46
project/examples/directory.umlg
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
base_class Object
|
||||
base_class Reference
|
||||
class Directory
|
||||
|
||||
public:
|
||||
Error open_dir(const String &path, bool skip_specials = true);
|
||||
Error open_dir(const char *path, bool skip_specials = true);
|
||||
void close_dir();
|
||||
|
||||
bool has_next();
|
||||
bool read();
|
||||
bool next();
|
||||
|
||||
bool current_is_ok();
|
||||
String current_get_name();
|
||||
String current_get_path();
|
||||
String current_get_extension();
|
||||
const char *current_get_name_cstr();
|
||||
const char *current_get_path_cstr();
|
||||
const char *current_get_extension_cstr();
|
||||
bool current_is_file();
|
||||
bool current_is_dir();
|
||||
bool current_is_special_dir();
|
||||
|
||||
String read_file(const String &path);
|
||||
Error read_file_into(const String &path, String *str);
|
||||
Vector<uint8_t> read_file_bin(const String &path);
|
||||
Error read_file_into_bin(const String &path, Vector<uint8_t> *data);
|
||||
|
||||
Error write_file(const String &path, const String &str);
|
||||
Error write_file_bin(const String &path, const Vector<uint8_t> &data);
|
||||
|
||||
bool is_dir_open();
|
||||
bool is_dir_closed();
|
||||
|
||||
Directory();
|
||||
virtual ~Directory();
|
||||
|
||||
private:
|
||||
bool _skip_specials;
|
||||
int _read_file_result;
|
||||
tinydir_dir _dir;
|
||||
tinydir_file _file;
|
||||
|
||||
bool _dir_open;
|
229
project/examples/string.umlg
Normal file
229
project/examples/string.umlg
Normal file
@ -0,0 +1,229 @@
|
||||
|
||||
class String
|
||||
public:
|
||||
void push_back(const char element);
|
||||
void push_back(const wchar_t element);
|
||||
void pop_back();
|
||||
void remove(const int index);
|
||||
void erase(const char element);
|
||||
void erase(const int start_index, const int length);
|
||||
void clear();
|
||||
bool empty() const;
|
||||
char get(const int index);
|
||||
const char get(const int index) const;
|
||||
void set(const int index, const char value);
|
||||
|
||||
int size() const;
|
||||
int capacity() const;
|
||||
void ensure_capacity(const int capacity);
|
||||
void resize(const int s);
|
||||
int find(const char val, const int from = 0) const;
|
||||
int find(const String &val, const int from = 0) const;
|
||||
int find_reversed(const char val, const int from = -1) const;
|
||||
int find_reversed(const String &val, const int from = -1) const;
|
||||
void get_substr(char *into_buf, const int start_index, const int len);
|
||||
void get_substr_nt(char *into_buf, const int start_index, const int len);
|
||||
String substr(const int start_index, const int len) const;
|
||||
String substr_index(const int start_index, const int end_index) const;
|
||||
bool contains(const char val) const;
|
||||
bool contains(const String &val) const;
|
||||
|
||||
bool is_word_at(const int index, const char *str) const;
|
||||
bool is_word_at(const int index, const String &val) const;
|
||||
|
||||
void replace_from(const int start_index, const int length, const String &with);
|
||||
void replace(const String &find_str, const String &with);
|
||||
void replace(const String &find_str, const String &with, const int count);
|
||||
|
||||
int compare(const String &other) const;
|
||||
|
||||
int first_difference_index(const String &other) const;
|
||||
|
||||
void to_lower();
|
||||
String as_lower() const;
|
||||
|
||||
void trim();
|
||||
void trim_beginning();
|
||||
void trim_end();
|
||||
|
||||
bool ends_with(const char c) const;
|
||||
bool ends_with(const String &str) const;
|
||||
|
||||
bool starts_with(const char c) const;
|
||||
bool starts_with(const String &str) const;
|
||||
|
||||
int get_slice_count(const char splitter) const;
|
||||
int get_slice_count(const String &splitter) const;
|
||||
String get_slice(const char splitter, int index);
|
||||
String get_slice(const String &splitter, int index);
|
||||
|
||||
Vector<String> split(const char splitter) const;
|
||||
Vector<String> split(const String &splitter) const;
|
||||
|
||||
uint8_t read_uint8_bytes_at(int &index, bool advance_index = true);
|
||||
uint16_t read_uint16_bytes_at(int &index, bool advance_index = true);
|
||||
uint32_t read_uint32_bytes_at(int &index, bool advance_index = true);
|
||||
uint64_t read_uint64_bytes_at(int &index, bool advance_index = true);
|
||||
|
||||
int8_t read_int8_bytes_at(int &index, bool advance_index = true);
|
||||
int16_t read_int16_bytes_at(int &index, bool advance_index = true);
|
||||
int32_t read_int32_bytes_at(int &index, bool advance_index = true);
|
||||
int64_t read_int64_bytes_at(int &index, bool advance_index = true);
|
||||
|
||||
void append_uint8_bytes(const uint8_t val);
|
||||
void append_uint16_bytes(const uint16_t val);
|
||||
void append_uint32_bytes(const uint32_t val);
|
||||
void append_uint64_bytes(const uint64_t val);
|
||||
|
||||
void append_int8_bytes(const int8_t val);
|
||||
void append_int16_bytes(const int16_t val);
|
||||
void append_int32_bytes(const int32_t val);
|
||||
void append_int64_bytes(const int64_t val);
|
||||
|
||||
float read_float_bytes_at(int &index, bool advance_index = true);
|
||||
void append_float_bytes(const float val);
|
||||
double read_double_bytes_at(int &index, bool advance_index = true);
|
||||
void append_double_bytes(const double val);
|
||||
|
||||
void append_str(const char *str);
|
||||
void append_str(const wchar_t *str);
|
||||
void append_str(const String &other);
|
||||
void append_str(const std::string &str);
|
||||
void append_str(const String &other, const int from);
|
||||
void append_str(const std::string &str, const int from);
|
||||
|
||||
void append_repeat(const char *str, const int times);
|
||||
void append_repeat(const String &other, const int times);
|
||||
|
||||
void append_path(const char *path);
|
||||
void append_path(const String &path);
|
||||
void path_clean_end_slash();
|
||||
void path_ensure_end_slash();
|
||||
String path_get_basename() const;
|
||||
String path_get_last_segment() const;
|
||||
String path_get_prev_dir() const;
|
||||
String file_get_extension() const;
|
||||
|
||||
void to_html_special_chars();
|
||||
void from_html_special_chars();
|
||||
void newline_to_br();
|
||||
|
||||
bool to_bool() const;
|
||||
float to_float() const;
|
||||
double to_double() const;
|
||||
int to_int() const;
|
||||
|
||||
bool is_bool() const;
|
||||
bool is_numeric() const;
|
||||
bool is_int() const;
|
||||
bool is_uint() const;
|
||||
bool is_zero() const;
|
||||
|
||||
uint32_t to_uint() const;
|
||||
std::string to_string() const;
|
||||
void print() const;
|
||||
|
||||
void append(const char *str);
|
||||
void append(const wchar_t *str);
|
||||
void append(const String &other);
|
||||
void append(const std::string &str);
|
||||
void append(const char chr);
|
||||
void append(const wchar_t chr);
|
||||
void append(const int num);
|
||||
void append(const unsigned int num);
|
||||
void append(const float num);
|
||||
void append(const double num);
|
||||
void append(const Variant &variant);
|
||||
|
||||
static String bool_num(bool val);
|
||||
static String bool_str(bool val);
|
||||
|
||||
static String num(double p_num, int p_decimals = -1);
|
||||
static String num_scientific(double p_num);
|
||||
static String num_real(double p_num, bool p_trailing = true);
|
||||
static String num_int64(int64_t p_num, int base = 10, bool capitalize_hex = false);
|
||||
static String num_uint64(uint64_t p_num, int base = 10, bool capitalize_hex = false);
|
||||
static String chr(char32_t p_char);
|
||||
|
||||
String ascii(bool p_allow_extended = false) const;
|
||||
String utf8() const;
|
||||
bool parse_utf8(const char *p_utf8, int p_len = -1); // return true on error
|
||||
static String utf8(const char *p_utf8, int p_len = -1);
|
||||
|
||||
static uint32_t hash(const wchar_t *p_cstr, int p_len); /* hash the string */
|
||||
static uint32_t hash(const wchar_t *p_cstr); /* hash the string */
|
||||
static uint32_t hash(const char *p_cstr, int p_len); /* hash the string */
|
||||
static uint32_t hash(const char *p_cstr); /* hash the string */
|
||||
uint32_t hash() const; /* hash the string */
|
||||
uint64_t hash64() const; /* hash the string */
|
||||
|
||||
char *c_str();
|
||||
const char *c_str() const;
|
||||
|
||||
char *dataw();
|
||||
const char *data() const;
|
||||
|
||||
const char operator[](const int index) const;
|
||||
char &operator[](const int index);
|
||||
|
||||
String &operator+=(const String &b);
|
||||
String &operator+=(const char chr);
|
||||
String &operator+=(const char *p_c_str);
|
||||
String &operator+=(const std::string &b);
|
||||
|
||||
friend String operator+(String lhs, const String &rhs);
|
||||
friend String operator+(String lhs, const char *rhs);
|
||||
friend String operator+(String lhs, const char rhs);
|
||||
friend String operator+(String lhs, const std::string &rhs);
|
||||
|
||||
friend bool operator==(const String &a, const String &b);
|
||||
friend bool operator!=(const String &a, const String &b);
|
||||
|
||||
friend bool operator==(const String &a, const char *b);
|
||||
friend bool operator!=(const String &a, const char *b);
|
||||
|
||||
friend bool operator==(const char *b, const String &a);
|
||||
friend bool operator!=(const char *b, const String &a);
|
||||
|
||||
friend bool operator==(const String &a, const wchar_t *b);
|
||||
friend bool operator!=(const String &a, const wchar_t *b);
|
||||
|
||||
friend bool operator==(const wchar_t *b, const String &a);
|
||||
friend bool operator!=(const wchar_t *b, const String &a);
|
||||
|
||||
friend bool operator==(const String &a, std::string &b);
|
||||
friend bool operator!=(const String &a, std::string &b);
|
||||
|
||||
friend bool operator==(std::string &b, const String &a);
|
||||
friend bool operator!=(std::string &b, const String &a);
|
||||
|
||||
friend bool operator<(const String &a, const String &b);
|
||||
friend bool operator>(const String &a, const String &b);
|
||||
friend bool operator<=(const String &a, const String &b);
|
||||
friend bool operator>=(const String &a, const String &b);
|
||||
|
||||
operator std::string() { return to_string(); }
|
||||
operator std::string() const { return to_string(); }
|
||||
|
||||
String &operator=(const String &other);
|
||||
String &operator=(const std::string &other);
|
||||
String &operator=(const char *other);
|
||||
String &operator=(const wchar_t *other);
|
||||
|
||||
String();
|
||||
String(const String &other);
|
||||
String(const String &other, const int grow_by);
|
||||
String(const char *p_c_str);
|
||||
String(const char *p_c_str, const int grow_by);
|
||||
String(const wchar_t *p_c_str);
|
||||
String(const int prealloc);
|
||||
String(const int prealloc, const int grow_by);
|
||||
String(const std::string &str);
|
||||
~String();
|
||||
|
||||
private:
|
||||
char *_data;
|
||||
int _actual_size;
|
||||
int _size;
|
||||
int _grow_by;
|
||||
|
BIN
project/frame.png
Normal file
BIN
project/frame.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 135 B |
35
project/frame.png.import
Normal file
35
project/frame.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/frame.png-3ac25dcfa39cb943440d117e36cbfa2f.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://frame.png"
|
||||
dest_files=[ "res://.import/frame.png-3ac25dcfa39cb943440d117e36cbfa2f.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
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
project/inherits.png
Normal file
BIN
project/inherits.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 165 B |
35
project/inherits.png.import
Normal file
35
project/inherits.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/inherits.png-a70912fbaeac42344d0cfe36cd571fe2.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://inherits.png"
|
||||
dest_files=[ "res://.import/inherits.png-a70912fbaeac42344d0cfe36cd571fe2.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
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
project/line.png
Normal file
BIN
project/line.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 93 B |
35
project/line.png.import
Normal file
35
project/line.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/line.png-e86270f75d5b95d6fc8473dba8c1eec6.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://line.png"
|
||||
dest_files=[ "res://.import/line.png-e86270f75d5b95d6fc8473dba8c1eec6.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
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
14
project/new_theme.tres
Normal file
14
project/new_theme.tres
Normal file
@ -0,0 +1,14 @@
|
||||
[gd_resource type="Theme" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://panel_bg_styleboxtexture.tres" type="StyleBox" id=1]
|
||||
|
||||
[resource]
|
||||
Button/colors/font_color = Color( 0, 0, 0, 1 )
|
||||
Button/colors/font_color_disabled = Color( 0.537255, 0.537255, 0.537255, 0.2 )
|
||||
Button/colors/font_color_focus = Color( 0.101961, 0.101961, 0.101961, 1 )
|
||||
Button/colors/font_color_hover = Color( 0.180392, 0.180392, 0.180392, 1 )
|
||||
Button/colors/font_color_pressed = Color( 0.294118, 0.294118, 0.294118, 1 )
|
||||
Label/colors/font_color = Color( 0, 0, 0, 1 )
|
||||
Label/colors/font_color_shadow = Color( 0.368627, 0.368627, 0.368627, 0 )
|
||||
Label/colors/font_outline_modulate = Color( 0.0823529, 0.0823529, 0.0823529, 1 )
|
||||
PanelContainer/styles/panel = ExtResource( 1 )
|
11
project/panel_bg_styleboxtexture.tres
Normal file
11
project/panel_bg_styleboxtexture.tres
Normal file
@ -0,0 +1,11 @@
|
||||
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://frame.png" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
texture = ExtResource( 1 )
|
||||
region_rect = Rect2( 0, 0, 32, 32 )
|
||||
margin_left = 4.0
|
||||
margin_right = 4.0
|
||||
margin_top = 4.0
|
||||
margin_bottom = 4.0
|
@ -22,4 +22,5 @@ common/enable_pause_aware_picking=true
|
||||
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 1, 1, 1, 1 )
|
||||
environment/default_environment="res://default_env.tres"
|
||||
|
Loading…
Reference in New Issue
Block a user