├── .gitattributes ├── .gitignore ├── D3hex.pbp ├── Data ├── Default.D3hex ├── Icons │ ├── Automatic.png │ ├── Close.png │ ├── Copy.png │ ├── Cut.png │ ├── Error.png │ ├── Folder.png │ ├── Gear.png │ ├── Goto.png │ ├── Graph_Dots.png │ ├── Graph_Fit_Y.png │ ├── Graph_Lines.png │ ├── Graph_Normalize.png │ ├── Graph_Normalize_X.png │ ├── Graph_Normalize_Y.png │ ├── Grid.png │ ├── Hilbert.png │ ├── Image_Fit_X.png │ ├── Image_Fit_Y.png │ ├── New.png │ ├── Node_Align.png │ ├── Node_Clear_Config.png │ ├── Node_Editor.png │ ├── Node_Grid_Snapping.png │ ├── Node_Load_Config.png │ ├── Node_Save_Config.png │ ├── Open_Clipboard.png │ ├── Open_File.png │ ├── Open_Network_Terminal.png │ ├── Open_Process.png │ ├── Open_Random.png │ ├── Paste.png │ ├── Redo.png │ ├── Refresh.png │ ├── Resize.png │ ├── Save.png │ ├── SaveAll.png │ ├── SaveAs.png │ ├── Search.png │ ├── Search_Continue.png │ ├── Select_All.png │ ├── Undo.png │ └── Warning.png ├── Images │ ├── Icon.cdr │ ├── Icon.ico │ ├── Icon.png │ ├── Icon_128.png │ ├── Icon_16.png │ ├── Icon_256.png │ ├── Icon_32.png │ ├── Icon_64.png │ ├── Logo.cdr │ ├── Logo.png │ ├── Logo_Big.png │ └── Logo_Small.png └── Scripts │ └── Julia_Node │ ├── Histogram │ └── Init.jl │ └── Random │ └── Init.jl ├── Includes ├── About.pbi ├── Constants.pbi ├── Crash.pbi ├── D3HT.pbi ├── D3NBT.pbi ├── D3docker │ ├── CustomGadget.pbi │ ├── D3docker.pbi │ ├── Data │ │ ├── Close.png │ │ ├── Diamond_Bottom.png │ │ ├── Diamond_Left.png │ │ ├── Diamond_Right.png │ │ ├── Diamond_Root_Bottom.png │ │ ├── Diamond_Root_Inside.png │ │ ├── Diamond_Root_Left.png │ │ ├── Diamond_Root_Right.png │ │ ├── Diamond_Root_Top.png │ │ ├── Diamond_Tabbed.png │ │ ├── Diamond_Top.png │ │ └── Undock.png │ └── TabBarGadget.pbi ├── Helper.pbi ├── Icons.pbi ├── Julia │ └── julia.pbi ├── Julia_API.pbi ├── Logger.pbi ├── Memory.pbi ├── Node.pbi ├── Node_Editor.pbi ├── Node_Type.pbi ├── Nodes │ ├── Binary_Operation │ │ └── Binary_Operation.pbi │ ├── Copy │ │ └── Copy.pbi │ ├── Data_Inspector │ │ └── Data_Inspector.pbi │ ├── Dummy │ │ └── Dummy.pbi │ ├── Editor │ │ ├── Editor.pbi │ │ ├── Editor_Goto.pbi │ │ └── Editor_Search.pbi │ ├── File │ │ └── File.pbi │ ├── Hash_Generator │ │ └── Hash_Generator.pbi │ ├── History │ │ └── History.pbi │ ├── Julia │ │ └── Julia.pbi │ ├── Math │ │ ├── Math.pbi │ │ └── MathFormula.pbi │ ├── Network_Terminal │ │ └── Network_Terminal.pbi │ ├── Process │ │ └── Process.pbi │ ├── Random │ │ └── Random.pbi │ ├── View1D │ │ ├── View1D.pbi │ │ └── View1D_Settings.pbi │ └── View2D │ │ ├── View2D.pbi │ │ └── View2D_Settings.pbi ├── UnitEngine.pbi ├── Window.pbi └── ZLib.pbi ├── LICENSE ├── Main.pb ├── README.md └── Screenshots ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 4_Small.png ├── Nodes_Simple.png ├── Object_Binary_Operation.png ├── Object_Copy.png ├── Object_Datatypes.png └── Open_File.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.exe 3 | Thumbs.db 4 | 5 | /Distribution 6 | /Test -------------------------------------------------------------------------------- /D3hex.pbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 |
7 |
8 | 9 | 10 | 11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 |
170 |
171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | Data\Images\Icon.ico 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | Data\Images\Icon.ico 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 |
207 |
208 | -------------------------------------------------------------------------------- /Data/Default.D3hex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Default.D3hex -------------------------------------------------------------------------------- /Data/Icons/Automatic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Automatic.png -------------------------------------------------------------------------------- /Data/Icons/Close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Close.png -------------------------------------------------------------------------------- /Data/Icons/Copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Copy.png -------------------------------------------------------------------------------- /Data/Icons/Cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Cut.png -------------------------------------------------------------------------------- /Data/Icons/Error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Error.png -------------------------------------------------------------------------------- /Data/Icons/Folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Folder.png -------------------------------------------------------------------------------- /Data/Icons/Gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Gear.png -------------------------------------------------------------------------------- /Data/Icons/Goto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Goto.png -------------------------------------------------------------------------------- /Data/Icons/Graph_Dots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Graph_Dots.png -------------------------------------------------------------------------------- /Data/Icons/Graph_Fit_Y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Graph_Fit_Y.png -------------------------------------------------------------------------------- /Data/Icons/Graph_Lines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Graph_Lines.png -------------------------------------------------------------------------------- /Data/Icons/Graph_Normalize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Graph_Normalize.png -------------------------------------------------------------------------------- /Data/Icons/Graph_Normalize_X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Graph_Normalize_X.png -------------------------------------------------------------------------------- /Data/Icons/Graph_Normalize_Y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Graph_Normalize_Y.png -------------------------------------------------------------------------------- /Data/Icons/Grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Grid.png -------------------------------------------------------------------------------- /Data/Icons/Hilbert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Hilbert.png -------------------------------------------------------------------------------- /Data/Icons/Image_Fit_X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Image_Fit_X.png -------------------------------------------------------------------------------- /Data/Icons/Image_Fit_Y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Image_Fit_Y.png -------------------------------------------------------------------------------- /Data/Icons/New.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/New.png -------------------------------------------------------------------------------- /Data/Icons/Node_Align.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Node_Align.png -------------------------------------------------------------------------------- /Data/Icons/Node_Clear_Config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Node_Clear_Config.png -------------------------------------------------------------------------------- /Data/Icons/Node_Editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Node_Editor.png -------------------------------------------------------------------------------- /Data/Icons/Node_Grid_Snapping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Node_Grid_Snapping.png -------------------------------------------------------------------------------- /Data/Icons/Node_Load_Config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Node_Load_Config.png -------------------------------------------------------------------------------- /Data/Icons/Node_Save_Config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Node_Save_Config.png -------------------------------------------------------------------------------- /Data/Icons/Open_Clipboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Open_Clipboard.png -------------------------------------------------------------------------------- /Data/Icons/Open_File.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Open_File.png -------------------------------------------------------------------------------- /Data/Icons/Open_Network_Terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Open_Network_Terminal.png -------------------------------------------------------------------------------- /Data/Icons/Open_Process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Open_Process.png -------------------------------------------------------------------------------- /Data/Icons/Open_Random.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Open_Random.png -------------------------------------------------------------------------------- /Data/Icons/Paste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Paste.png -------------------------------------------------------------------------------- /Data/Icons/Redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Redo.png -------------------------------------------------------------------------------- /Data/Icons/Refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Refresh.png -------------------------------------------------------------------------------- /Data/Icons/Resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Resize.png -------------------------------------------------------------------------------- /Data/Icons/Save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Save.png -------------------------------------------------------------------------------- /Data/Icons/SaveAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/SaveAll.png -------------------------------------------------------------------------------- /Data/Icons/SaveAs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/SaveAs.png -------------------------------------------------------------------------------- /Data/Icons/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Search.png -------------------------------------------------------------------------------- /Data/Icons/Search_Continue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Search_Continue.png -------------------------------------------------------------------------------- /Data/Icons/Select_All.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Select_All.png -------------------------------------------------------------------------------- /Data/Icons/Undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Undo.png -------------------------------------------------------------------------------- /Data/Icons/Warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Icons/Warning.png -------------------------------------------------------------------------------- /Data/Images/Icon.cdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon.cdr -------------------------------------------------------------------------------- /Data/Images/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon.ico -------------------------------------------------------------------------------- /Data/Images/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon.png -------------------------------------------------------------------------------- /Data/Images/Icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon_128.png -------------------------------------------------------------------------------- /Data/Images/Icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon_16.png -------------------------------------------------------------------------------- /Data/Images/Icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon_256.png -------------------------------------------------------------------------------- /Data/Images/Icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon_32.png -------------------------------------------------------------------------------- /Data/Images/Icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Icon_64.png -------------------------------------------------------------------------------- /Data/Images/Logo.cdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Logo.cdr -------------------------------------------------------------------------------- /Data/Images/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Logo.png -------------------------------------------------------------------------------- /Data/Images/Logo_Big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Logo_Big.png -------------------------------------------------------------------------------- /Data/Images/Logo_Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Data/Images/Logo_Small.png -------------------------------------------------------------------------------- /Data/Scripts/Julia_Node/Histogram/Init.jl: -------------------------------------------------------------------------------- 1 | module Node_Histogram 2 | 3 | using PB, Logger, Node, Node_Julia 4 | 5 | type Object 6 | node_id::Int64 7 | 8 | histogram_max::Float32 9 | histogram_min::Float32 10 | histogram::Array{Float32, 2} 11 | 12 | input::Ptr{Node.Conn_Input} 13 | output::Ptr{Node.Conn_Output} 14 | 15 | function Object(node_id::Int64) 16 | this = new(node_id) 17 | node = Node.Get(this.node_id) 18 | 19 | this.input = Node_Julia.Input_Add(node, "", "") 20 | Node_Julia.Input_Callback(this.input, "Event", Input_Callback_Event) 21 | 22 | this.output = Node_Julia.Output_Add(node, "", "") 23 | Node_Julia.Output_Callback(this.output, "Get_Size", Output_Callback_Get_Size) 24 | Node_Julia.Output_Callback(this.output, "Get_Data", Output_Callback_Get_Data) 25 | 26 | this 27 | end 28 | end 29 | 30 | function Input_Callback_Event(this::Object, input::Ptr{Void}, event::Ptr{Void}) 31 | event = convert(Ptr{Node.Event}, event) # Hackish way until i pass the right type directly 32 | event = unsafe_load(event) 33 | 34 | if event.event_type == Node.Link_Event_Update 35 | Update_Histogram(this) 36 | end 37 | 38 | return 1 39 | end 40 | 41 | function Output_Callback_Get_Size(this::Object, output::Ptr{Void}) 42 | return 256 * 256 43 | end 44 | 45 | function Output_Callback_Get_Data(this::Object, output::Ptr{Void}, position::Int64, data::Array{UInt8,1}, metadata::Array{UInt8,1}) 46 | # Get and flatten histogram data 47 | local histogram = this.histogram[:] 48 | local max_value = this.histogram_max 49 | local min_value = this.histogram_min 50 | 51 | # Get size 52 | size = min(length(histogram) - position, length(data), length(metadata)) 53 | if size <= 0 54 | return 0 55 | end 56 | 57 | # Get only the slice of data, which is needed 58 | histogram = histogram[position+1:position+size] 59 | 60 | # Nonlinear scale 61 | histogram = sqrt(histogram) 62 | max_value = sqrt(max_value) 63 | min_value = sqrt(min_value) 64 | 65 | # Normalize array 66 | if min_value != max_value 67 | histogram = (histogram - min_value) / (max_value - min_value) * 255 68 | end 69 | 70 | # Customc scaling 71 | histogram *= 10 72 | 73 | # Limit range to UInt8 74 | @simd for i in 1:length(histogram) 75 | @inbounds if histogram[i] > 255 76 | histogram[i] = 255 77 | end 78 | end 79 | 80 | # Flatten array and change its type 81 | histogram = floor(UInt8, histogram[:]) 82 | 83 | # Copy data 84 | data[1:size] .= histogram 85 | metadata[1:size] .= 0b10000001 86 | 87 | return 1 88 | end 89 | 90 | function Update_Histogram(this::Object) 91 | inputsize = Node.Input_Get_Size(this.input) 92 | 93 | if inputsize >= 0 94 | inputdata = zeros(UInt8, inputsize) 95 | if Node.Input_Get_Data(this.input, 0, inputdata) == 0 96 | this.histogram = zeros(UInt8, 0) 97 | return false 98 | end 99 | else 100 | inputdata = zeros(UInt8, 0) 101 | end 102 | 103 | histogram = zeros(Float32, 256, 256) 104 | max_value = 0 105 | for i in 1:length(inputdata)-1 106 | histogram[inputdata[i]+1, inputdata[i+1]+1] += 1 107 | if max_value < histogram[inputdata[i]+1, inputdata[i+1]+1] 108 | max_value = histogram[inputdata[i]+1, inputdata[i+1]+1] 109 | end 110 | end 111 | 112 | # Write to object 113 | this.histogram = histogram 114 | this.histogram_max = max_value 115 | this.histogram_min = minimum(histogram) 116 | 117 | # Send event out of the output 118 | event = Node.Event(Node.Link_Event_Update, 0, 256 * 256) 119 | Node.Output_Event(this.output, event) 120 | 121 | return true 122 | end 123 | 124 | end -------------------------------------------------------------------------------- /Data/Scripts/Julia_Node/Random/Init.jl: -------------------------------------------------------------------------------- 1 | module Node_Test 2 | 3 | using PB, Logger, Node, Node_Julia 4 | 5 | type Object 6 | node_id::Int64 7 | 8 | output::Ptr{Node.Conn_Output} 9 | 10 | number::Int64 11 | 12 | function Object(node_id::Int64) 13 | this = new(node_id) 14 | node = Node.Get(this.node_id) 15 | 16 | this.output = Node_Julia.Output_Add(node, "Hello World", "Hi") 17 | Node_Julia.Output_Callback(this.output, "Get_Size", Output_Callback_Get_Size) 18 | Node_Julia.Output_Callback(this.output, "Get_Data", Output_Callback_Get_Data) 19 | 20 | finalizer(this, (t)->PB.Debug(string(t) * " finalized!")) 21 | 22 | this 23 | end 24 | end 25 | 26 | function Output_Callback_Get_Size(this::Object, output::Ptr{Void}) 27 | 28 | #gc() 29 | 30 | #PB.Debug("Hi thar!") 31 | #PB.Debug(string(this)) 32 | #Logger.Entry_Add_Error("Hey", "Test") 33 | this.number = this.number + 1 34 | return 1000000000#this.number 35 | end 36 | 37 | function fastrand(state::UInt) 38 | state $= state << 13 39 | state $= state >> 17 40 | state $= state << 5 41 | #state = (214013 * state + 2531011) 42 | return state, convert(UInt8, (state >> 16) & 0xFF) 43 | end 44 | 45 | function random_fastrand!(position::Int64, data::Array{UInt8,1}) 46 | const chunk_size = 512 47 | 48 | chunk_number = div(position, chunk_size) 49 | chunk_position = chunk_number * chunk_size 50 | state = convert(UInt, chunk_position+1) 51 | # Omit first random values 52 | @simd for i in 1:10 53 | state, a = fastrand(state) 54 | end 55 | counter = chunk_size 56 | @simd for i in chunk_position:position-1 57 | state, a = fastrand(state) 58 | counter -= 1 59 | end 60 | 61 | @simd for i in 1:length(data) 62 | @inbounds state, data[i] = fastrand(state) 63 | counter -= 1 64 | if counter <= 0 65 | chunk_number += 1 66 | chunk_position = chunk_number * chunk_size 67 | state = convert(UInt, chunk_position+1) 68 | # Omit first random values 69 | @simd for i in 1:10 70 | state, a = fastrand(state) 71 | end 72 | counter = chunk_size 73 | end 74 | end 75 | end 76 | 77 | function random_mersenne!(position::Int64, data::Array{UInt8,1}) 78 | const chunk_size = 1024 79 | 80 | chunk_number = div(position, chunk_size) 81 | chunk_position = chunk_number * chunk_size 82 | 83 | rng = MersenneTwister(chunk_position) 84 | counter = chunk_size 85 | @simd for i in chunk_position:position-1 86 | rand(rng, UInt8) 87 | counter -= 1 88 | end 89 | 90 | @simd for i in 1:length(data) 91 | @inbounds data[i] = rand(rng, UInt8) 92 | counter -= 1 93 | if counter <= 0 94 | chunk_number += 1 95 | chunk_position = chunk_number * chunk_size 96 | srand(rng, chunk_position) 97 | counter = chunk_size 98 | end 99 | end 100 | end 101 | 102 | function Output_Callback_Get_Data(this::Object, output::Ptr{Void}, position::Int64, data::Array{UInt8,1}, metadata::Array{UInt8,1}) 103 | metadata .= 0b10000001 104 | 105 | random_fastrand!(position, data) 106 | 107 | 1 108 | end 109 | 110 | end -------------------------------------------------------------------------------- /Includes/About.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ##################################################### Includes #################################################### 28 | 29 | ; ################################################################################################################### 30 | ; ##################################################### Public ###################################################### 31 | ; ################################################################################################################### 32 | 33 | DeclareModule About 34 | EnableExplicit 35 | ; ################################################### Constants ################################################### 36 | 37 | ; ################################################### Functions ################################################### 38 | Declare Open() 39 | Declare Close() 40 | Declare Main() 41 | 42 | EndDeclareModule 43 | 44 | ; ################################################################################################################### 45 | ; ##################################################### Private ##################################################### 46 | ; ################################################################################################################### 47 | 48 | Module About 49 | 50 | ; ##################################################### Includes #################################################### 51 | 52 | ; ##################################################### Prototypes ################################################## 53 | 54 | ; ##################################################### Structures ################################################## 55 | 56 | ; ##################################################### Constants ################################################### 57 | 58 | ; ##################################################### Structures ################################################## 59 | 60 | Structure Main 61 | 62 | EndStructure 63 | Global Main.Main 64 | 65 | Structure About 66 | Window_ID.i 67 | Window_Close.l 68 | 69 | ; #### Gadgets 70 | Canvas.i 71 | Editor.i 72 | 73 | Redraw.l 74 | EndStructure 75 | Global About.About 76 | 77 | ; ##################################################### Variables ################################################### 78 | 79 | ; ##################################################### Icons ... ################################################### 80 | 81 | ; ##################################################### Init ######################################################## 82 | 83 | Global Image_Logo = CatchImage(#PB_Any, ?Image_Logo) 84 | 85 | Global Font = LoadFont(#PB_Any, "Courier New", 10) 86 | 87 | ; ##################################################### Procedures ################################################## 88 | 89 | Procedure Canvas_Redraw() 90 | Protected Width = GadgetWidth(About\Canvas) 91 | Protected Height = GadgetHeight(About\Canvas) 92 | Protected Text.s = "V. "+StrF(Main::Main\Version*0.001, 3) 93 | 94 | If StartDrawing(CanvasOutput(About\Canvas)) 95 | 96 | Box(0, 0, Width, Height, RGB(220,220,220)) 97 | 98 | DrawImage(ImageID(Image_Logo), 0, 0, Width, Height) 99 | 100 | DrawingMode(#PB_2DDrawing_Transparent) 101 | DrawingFont(FontID(Font)) 102 | DrawText(Width-TextWidth(Text), Height-TextHeight(Text), Text, RGB(255,255,255)) 103 | 104 | StopDrawing() 105 | EndIf 106 | EndProcedure 107 | 108 | Procedure Editor_Fill() 109 | Protected Description.s, Temp_Text.s 110 | 111 | ClearGadgetItems(About\Editor) 112 | 113 | SetGadgetFont(About\Editor, FontID(Font)) 114 | 115 | AddGadgetItem(About\Editor, -1, " ╔══════════════════════════╗") 116 | AddGadgetItem(About\Editor, -1, " ║ D3hex V."+StrF(Main::Main\Version*0.001, 3)+" ║") 117 | AddGadgetItem(About\Editor, -1, " ╟──────────────────────────╢") 118 | AddGadgetItem(About\Editor, -1, " ║ A node based hex-editor ║") 119 | AddGadgetItem(About\Editor, -1, " ╚══════════════════════════╝") 120 | AddGadgetItem(About\Editor, -1, "") 121 | AddGadgetItem(About\Editor, -1, "Programmer: David Vogel (Dadido3, Xaardas)") 122 | AddGadgetItem(About\Editor, -1, "Website: www.D3nexus.de") 123 | AddGadgetItem(About\Editor, -1, "Repository: www.github.com/Dadido3/D3hex") 124 | AddGadgetItem(About\Editor, -1, "") 125 | AddGadgetItem(About\Editor, -1, "╔══════════════════════╗") 126 | AddGadgetItem(About\Editor, -1, "║ Compilation: ║") 127 | AddGadgetItem(About\Editor, -1, "╚══════════════════════╝") 128 | AddGadgetItem(About\Editor, -1, "") 129 | AddGadgetItem(About\Editor, -1, "Times compiled: "+Str(#PB_Editor_CompileCount)) 130 | AddGadgetItem(About\Editor, -1, "Times built: "+Str(#PB_Editor_BuildCount)) 131 | AddGadgetItem(About\Editor, -1, "Build Timestamp: "+FormatDate("%hh:%ii:%ss %dd.%mm.%yyyy", #PB_Compiler_Date)) 132 | CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 133 | AddGadgetItem(About\Editor, -1, "Compiled with PureBasic "+StrF(#PB_Compiler_Version/100, 2)+" (x86)") 134 | CompilerElse 135 | AddGadgetItem(About\Editor, -1, "Compiled with PureBasic "+StrF(#PB_Compiler_Version/100, 2)+" (x64)") 136 | CompilerEndIf 137 | AddGadgetItem(About\Editor, -1, "") 138 | AddGadgetItem(About\Editor, -1, "╔══════════════════════╗") 139 | AddGadgetItem(About\Editor, -1, "║ Thanks to: ║") 140 | AddGadgetItem(About\Editor, -1, "╚══════════════════════╝") 141 | AddGadgetItem(About\Editor, -1, "") 142 | AddGadgetItem(About\Editor, -1, "► Stargate for his TabBarGadget") 143 | AddGadgetItem(About\Editor, -1, "► The PureBasic community as a good source for help and information") 144 | AddGadgetItem(About\Editor, -1, "► Jean-loup Gailly and Mark Adler for zlib") 145 | AddGadgetItem(About\Editor, -1, "") 146 | AddGadgetItem(About\Editor, -1, "╔══════════════════════╗") 147 | AddGadgetItem(About\Editor, -1, "║ License: ║") 148 | AddGadgetItem(About\Editor, -1, "╚══════════════════════╝") 149 | AddGadgetItem(About\Editor, -1, "") 150 | AddGadgetItem(About\Editor, -1, "This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.") 151 | AddGadgetItem(About\Editor, -1, "") 152 | AddGadgetItem(About\Editor, -1, "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.") 153 | AddGadgetItem(About\Editor, -1, "") 154 | AddGadgetItem(About\Editor, -1, "You should have received a copy of the GNU General Public License along with this program. If not, see .") 155 | AddGadgetItem(About\Editor, -1, "") 156 | AddGadgetItem(About\Editor, -1, "╔══════════════════════╗") 157 | AddGadgetItem(About\Editor, -1, "║ Available nodes: ║") 158 | AddGadgetItem(About\Editor, -1, "╠══════════════════════╩═════════════════════════════════╗") 159 | ForEach Node_Type::Object() 160 | AddGadgetItem(About\Editor, -1, "║ Name: "+LSet(Node_Type::Object()\Name, 48)+ " ║") 161 | AddGadgetItem(About\Editor, -1, "║ UID: "+Node_Type::Object()\UID+" Version: "+StrF(Node_Type::Object()\Version*0.001, 3)+" ║") 162 | Description = "Description: "+Node_Type::Object()\Description 163 | Repeat 164 | Temp_Text = LSet(Description, 54) 165 | Description = Mid(Description, 54) 166 | AddGadgetItem(About\Editor, -1, "║ "+Temp_Text+" ║") 167 | Until Description = "" 168 | AddGadgetItem(About\Editor, -1, "╟────────────────────────────────────────────────────────╢") 169 | AddGadgetItem(About\Editor, -1, "║ Created: "+FormatDate("%hh:%ii:%ss %dd.%mm.%yyyy", Node_Type::Object()\Date_Creation)+" ║") 170 | AddGadgetItem(About\Editor, -1, "║ Modified: "+FormatDate("%hh:%ii:%ss %dd.%mm.%yyyy", Node_Type::Object()\Date_Modification)+" ║") 171 | AddGadgetItem(About\Editor, -1, "║ Compiled: "+FormatDate("%hh:%ii:%ss %dd.%mm.%yyyy", Node_Type::Object()\Date_Compilation)+" ║") 172 | AddGadgetItem(About\Editor, -1, "║ Author: "+LSet(Node_Type::Object()\Author, 44)+ " ║") 173 | AddGadgetItem(About\Editor, -1, "╠════════════════════════════════════════════════════════╣") 174 | Next 175 | EndProcedure 176 | 177 | Procedure Event_Canvas() 178 | Protected Event_Window = EventWindow() 179 | Protected Event_Gadget = EventGadget() 180 | Protected Event_Type = EventType() 181 | 182 | 183 | EndProcedure 184 | 185 | Procedure Event_SizeWindow() 186 | Protected Event_Window = EventWindow() 187 | Protected Event_Gadget = EventGadget() 188 | Protected Event_Type = EventType() 189 | 190 | 191 | About\Redraw = #True 192 | EndProcedure 193 | 194 | Procedure Event_ActivateWindow() 195 | Protected Event_Window = EventWindow() 196 | Protected Event_Gadget = EventGadget() 197 | Protected Event_Type = EventType() 198 | 199 | About\Redraw = #True 200 | EndProcedure 201 | 202 | Procedure Event_Menu() 203 | Protected Event_Window = EventWindow() 204 | Protected Event_Gadget = EventGadget() 205 | Protected Event_Type = EventType() 206 | Protected Event_Menu = EventMenu() 207 | 208 | EndProcedure 209 | 210 | Procedure Event_CloseWindow() 211 | Protected Event_Window = EventWindow() 212 | Protected Event_Gadget = EventGadget() 213 | Protected Event_Type = EventType() 214 | 215 | ;Close() 216 | About\Window_Close = #True 217 | EndProcedure 218 | 219 | Procedure Open() 220 | Protected Width, Height 221 | 222 | If About\Window_ID = 0 223 | 224 | Width = 500 225 | Height = 600 226 | 227 | About\Window_ID = OpenWindow(#PB_Any, 0, 0, Width, Height, "About", #PB_Window_SystemMenu | #PB_Window_WindowCentered, WindowID(Main::Window\ID)) 228 | 229 | About\Canvas = CanvasGadget(#PB_Any, 0, 0, Width, 279) 230 | About\Editor = EditorGadget(#PB_Any, 0, 279, Width, Height-279, #PB_Editor_ReadOnly | #PB_Editor_WordWrap) 231 | 232 | Editor_Fill() 233 | 234 | BindGadgetEvent(About\Canvas, @Event_Canvas()) 235 | 236 | BindEvent(#PB_Event_SizeWindow, @Event_SizeWindow(), About\Window_ID) 237 | ;BindEvent(#PB_Event_Repaint, @Event_SizeWindow(), About\Window_ID) 238 | ;BindEvent(#PB_Event_RestoreWindow, @Event_SizeWindow(), About\Window_ID) 239 | BindEvent(#PB_Event_Menu, @Event_Menu(), About\Window_ID) 240 | BindEvent(#PB_Event_CloseWindow, @Event_CloseWindow(), About\Window_ID) 241 | 242 | About\Redraw = #True 243 | 244 | EndIf 245 | EndProcedure 246 | 247 | Procedure Close() 248 | If About\Window_ID 249 | 250 | UnbindGadgetEvent(About\Canvas, @Event_Canvas()) 251 | 252 | UnbindEvent(#PB_Event_SizeWindow, @Event_SizeWindow(), About\Window_ID) 253 | ;UnbindEvent(#PB_Event_Repaint, @Event_SizeWindow(), About\Window_ID) 254 | ;UnbindEvent(#PB_Event_RestoreWindow, @Event_SizeWindow(), About\Window_ID) 255 | UnbindEvent(#PB_Event_Menu, @Event_Menu(), About\Window_ID) 256 | UnbindEvent(#PB_Event_CloseWindow, @Event_CloseWindow(), About\Window_ID) 257 | 258 | CloseWindow(About\Window_ID) 259 | About\Window_ID = 0 260 | EndIf 261 | EndProcedure 262 | 263 | Procedure Main() 264 | If Not About\Window_ID 265 | ProcedureReturn #False 266 | EndIf 267 | 268 | If About\Redraw 269 | About\Redraw = #False 270 | Canvas_Redraw() 271 | EndIf 272 | 273 | If About\Window_Close 274 | About\Window_Close = #False 275 | Close() 276 | EndIf 277 | 278 | EndProcedure 279 | 280 | ; ##################################################### Initialisation ############################################## 281 | 282 | 283 | 284 | ; ##################################################### Data Sections ############################################### 285 | 286 | DataSection 287 | Image_Logo: 288 | IncludeBinary "../Data/Images/Logo.png" 289 | EndDataSection 290 | 291 | EndModule 292 | 293 | ; IDE Options = PureBasic 5.31 (Windows - x64) 294 | ; CursorPosition = 229 295 | ; FirstLine = 214 296 | ; Folding = -- 297 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Constants.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; 28 | ; ################################################################################################################### 29 | ; ##################################################### Public ###################################################### 30 | ; ################################################################################################################### 31 | 32 | DeclareModule Constants 33 | EnableExplicit 34 | ; ################################################### Constants ################################################### 35 | Enumeration 36 | #Data_Raw 37 | #Integer_U_8 ; = #PB_Ascii 38 | #Integer_S_8 ; = #PB_Byte 39 | #Integer_U_16 ; = #PB_Unicode 40 | #Integer_S_16 ; = #PB_Word 41 | #Integer_U_32 ; = #PB_Long (Unsigned) 42 | #Integer_S_32 ; = #PB_Long 43 | #Integer_U_64 ; = #PB_Quad (Unsigned) 44 | #Integer_S_64 ; = #PB_Quad 45 | #Float_32 ; = #PB_Float 46 | #Float_64 ; = #PB_Double 47 | #String_Ascii 48 | #String_UTF8 49 | #String_UTF16 50 | #String_UTF32 51 | #String_UCS2 52 | #String_UCS4 53 | EndEnumeration 54 | 55 | Enumeration ; Image Pixelformat. Number is in bpp 56 | #PixelFormat_1_Gray 57 | #PixelFormat_1_Indexed 58 | #PixelFormat_2_Gray 59 | #PixelFormat_2_Indexed 60 | #PixelFormat_4_Gray 61 | #PixelFormat_4_Indexed 62 | #PixelFormat_8_Gray 63 | #PixelFormat_8_Indexed 64 | #PixelFormat_16_Gray 65 | #PixelFormat_16_RGB_555 66 | #PixelFormat_16_RGB_565 67 | #PixelFormat_16_ARGB_1555 68 | #PixelFormat_16_Indexed 69 | #PixelFormat_24_RGB 70 | #PixelFormat_24_BGR 71 | #PixelFormat_32_ARGB 72 | #PixelFormat_32_ABGR 73 | EndEnumeration 74 | 75 | #Metadata_Readable = %00000001 76 | #Metadata_Writeable = %00000010 77 | #Metadata_Executable = %00000100 78 | #Metadata_Changed = %01000000 79 | #Metadata_NoError = %10000000 80 | 81 | Enumeration 82 | ; #### Add custom global drag and drop constants here 83 | 84 | #DragDrop_Private_Node_New ; A new node is being dragged 85 | EndEnumeration 86 | 87 | EndDeclareModule 88 | 89 | ; ################################################################################################################### 90 | ; ##################################################### Private ##################################################### 91 | ; ################################################################################################################### 92 | 93 | Module Constants 94 | 95 | EndModule 96 | 97 | ; IDE Options = PureBasic 5.42 LTS (Windows - x64) 98 | ; CursorPosition = 46 99 | ; FirstLine = 26 100 | ; EnableUnicode 101 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Crash.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | 28 | ; ##################################################### Includes #################################################### 29 | 30 | ; ##################################################### Prototypes ################################################## 31 | 32 | ; ##################################################### Structures ################################################## 33 | 34 | ; ##################################################### Constants ################################################### 35 | 36 | ; ##################################################### Structures ################################################## 37 | 38 | Structure Crash_Main 39 | 40 | EndStructure 41 | Global Crash_Main.Crash_Main 42 | 43 | ; ##################################################### Variables ################################################### 44 | 45 | ; ##################################################### Icons ... ################################################### 46 | 47 | ; ##################################################### Init ######################################################## 48 | 49 | ; ##################################################### Declares #################################################### 50 | 51 | ; ##################################################### Procedures ################################################## 52 | 53 | Procedure Crash_Handler() 54 | OpenConsole() 55 | 56 | PrintN("A program crash was detected:") 57 | PrintN("") 58 | PrintN("Error Message: " + ErrorMessage()) 59 | PrintN("Error Code: " + Str(ErrorCode())) 60 | PrintN("Code Address: " + Str(ErrorAddress())) 61 | If ErrorCode() = #PB_OnError_InvalidMemory 62 | PrintN("Target Address: " + Str(ErrorTargetAddress())) 63 | EndIf 64 | PrintN("Thread: " + Str(#PB_Compiler_Thread)) 65 | PrintN("") 66 | If ErrorLine() = -1 67 | PrintN("Sourcecode line: Enable OnError lines support to get code line information.") 68 | Else 69 | PrintN("Sourcecode line: " + Str(ErrorLine())) 70 | PrintN("Sourcecode file: " + ErrorFile()) 71 | EndIf 72 | 73 | PrintN("") 74 | PrintN("Register content:") 75 | 76 | CompilerSelect #PB_Compiler_Processor 77 | CompilerCase #PB_Processor_x86 78 | PrintN("EAX = " + Str(ErrorRegister(#PB_OnError_EAX))) 79 | PrintN("EBX = " + Str(ErrorRegister(#PB_OnError_EBX))) 80 | PrintN("ECX = " + Str(ErrorRegister(#PB_OnError_ECX))) 81 | PrintN("EDX = " + Str(ErrorRegister(#PB_OnError_EDX))) 82 | PrintN("EBP = " + Str(ErrorRegister(#PB_OnError_EBP))) 83 | PrintN("ESI = " + Str(ErrorRegister(#PB_OnError_ESI))) 84 | PrintN("EDI = " + Str(ErrorRegister(#PB_OnError_EDI))) 85 | PrintN("ESP = " + Str(ErrorRegister(#PB_OnError_ESP))) 86 | 87 | CompilerCase #PB_Processor_x64 88 | PrintN("RAX = " + Str(ErrorRegister(#PB_OnError_RAX))) 89 | PrintN("RBX = " + Str(ErrorRegister(#PB_OnError_RBX))) 90 | PrintN("RCX = " + Str(ErrorRegister(#PB_OnError_RCX))) 91 | PrintN("RDX = " + Str(ErrorRegister(#PB_OnError_RDX))) 92 | PrintN("RBP = " + Str(ErrorRegister(#PB_OnError_RBP))) 93 | PrintN("RSI = " + Str(ErrorRegister(#PB_OnError_RSI))) 94 | PrintN("RDI = " + Str(ErrorRegister(#PB_OnError_RDI))) 95 | PrintN("RSP = " + Str(ErrorRegister(#PB_OnError_RSP))) 96 | PrintN("R8 = " + Str(ErrorRegister(#PB_OnError_R8))) 97 | PrintN("R9 = " + Str(ErrorRegister(#PB_OnError_R9))) 98 | PrintN("R10 = " + Str(ErrorRegister(#PB_OnError_R10))) 99 | PrintN("R11 = " + Str(ErrorRegister(#PB_OnError_R11))) 100 | PrintN("R12 = " + Str(ErrorRegister(#PB_OnError_R12))) 101 | PrintN("R13 = " + Str(ErrorRegister(#PB_OnError_R13))) 102 | PrintN("R14 = " + Str(ErrorRegister(#PB_OnError_R14))) 103 | PrintN("R15 = " + Str(ErrorRegister(#PB_OnError_R15))) 104 | 105 | CompilerEndSelect 106 | 107 | Input() 108 | 109 | End 110 | EndProcedure 111 | 112 | CompilerIf #PB_Compiler_Debugger = #False 113 | OnErrorCall(@Crash_Handler()) 114 | CompilerEndIf 115 | 116 | ; ##################################################### Initialisation ############################################## 117 | 118 | 119 | 120 | ; ##################################################### Data Sections ############################################### 121 | 122 | ; IDE Options = PureBasic 5.31 (Windows - x64) 123 | ; CursorPosition = 3 124 | ; Folding = - 125 | ; EnableUnicode 126 | ; EnableXP -------------------------------------------------------------------------------- /Includes/D3docker/CustomGadget.pbi: -------------------------------------------------------------------------------- 1 | ;-TOP 2 | ; Comment : Create custom PB gadget 3 | ; Author : eddy 4 | ; Web : http://www.purebasic.fr/english/viewtopic.php?f=12&p=418722 5 | ; File: : CustomGadget.pbi 6 | ; Version : v0.7 7 | 8 | DeclareModule CustomGadget 9 | Prototype Events(*Params, EventWindow, EventGadget, EventType) 10 | Prototype Call(*Gadget) 11 | Prototype CallByItem(*Gadget, Item) 12 | Prototype Resize(*Gadget, x.l, y.l, w.l, h.l) 13 | Prototype.i GetInteger(*Gadget) 14 | Prototype SetInteger(*Gadget, Value) 15 | Prototype.s GetString(*Gadget) 16 | Prototype SetString(*Gadget, Value$) 17 | Prototype.s GetStringByItem(*Gadget, Item) 18 | Prototype SetStringByItem(*Gadget, Item, Value$) 19 | Prototype.i GetIntegerByAttribute(*Gadget, Attribute) 20 | Prototype SetIntegerByAttribute(*Gadget, Attribute, Value) 21 | Prototype.i GetIntegerByItem(*Gadget, Item) 22 | Prototype SetIntegerByItemAttribute(*Gadget, Item, Attribute, Value, Column=#PB_Ignore) 23 | Prototype.i GetIntegerByItemAttribute(*Gadget, Item, Attribute, Column=#PB_Ignore) 24 | Prototype SetIntegerByItem(*Gadget, Item, Value) 25 | Structure GADGET_VT 26 | GadgetType.l ; gadget type (used by GadgetType command) 27 | SizeOf.l ; Size of structure 28 | 29 | *GadgetCallback 30 | *FreeGadget.Call 31 | *GetGadgetState.GetInteger 32 | *SetGadgetState.SetInteger 33 | *GetGadgetText.GetString 34 | *SetGadgetText.SetString 35 | *AddGadgetItem2 36 | *AddGadgetItem3 37 | *RemoveGadgetItem.CallByItem 38 | *ClearGadgetItems.Call 39 | *ResizeGadget.Resize 40 | *CountGadgetItems.GetInteger 41 | *GetGadgetItemState.GetIntegerByItem 42 | *SetGadgetItemState.SetIntegerByItem 43 | *GetGadgetItemText.GetStringByItem 44 | *SetGadgetItemText.SetStringByItem 45 | *OpenGadgetList2 46 | *GadgetX.GetInteger 47 | *GadgetY.GetInteger 48 | *GadgetWidth.GetInteger 49 | *GadgetHeight.GetInteger 50 | *HideGadget.SetInteger 51 | *AddGadgetColumn 52 | *RemoveGadgetColumn 53 | *GetGadgetAttribute.GetIntegerByAttribute 54 | *SetGadgetAttribute.SetIntegerByAttribute 55 | *GetGadgetItemAttribute.GetIntegerByItemAttribute 56 | *SetGadgetItemAttribute.SetIntegerByItemAttribute 57 | *SetGadgetColor 58 | *GetGadgetColor 59 | *SetGadgetItemColor2 60 | *GetGadgetItemColor2 61 | *SetGadgetItemData 62 | *GetGadgetItemData 63 | *GetRequiredSize 64 | *SetActiveGadget 65 | *GetGadgetFont 66 | *SetGadgetFont 67 | *SetGadgetItemImage 68 | EndStructure 69 | Structure GADGET 70 | *Handle ; gadget OS handle 71 | *VT.GADGET_VT ; gadget commands 72 | *UserData ; gadget data (used by SetGadgetData) 73 | *OldCallback ; original OS callback (used by purebasic CALLBACK) 74 | Daten.i[4] ; ..... 75 | EndStructure 76 | Structure GADGET_MANAGER 77 | GadgetCount.i ;gadget counter (optional) 78 | *OldVT.GADGET_VT ;old commands pointers 79 | *NewVT.GADGET_VT ;new commands pointers 80 | Map *GadgetParams() ;gadget custom parameters 81 | EndStructure 82 | 83 | Declare ManageGadgetCommands(*manager.GADGET_MANAGER, Gadget, State) 84 | Declare ManageGadget(*manager.GADGET_MANAGER, Gadget, *params, GadgetType) 85 | Declare UnmanageGadget(*manager.GADGET_MANAGER, Gadget) 86 | EndDeclareModule 87 | 88 | Module CustomGadget 89 | EnableExplicit 90 | Procedure ManageGadgetCommands(*manager.GADGET_MANAGER, Gadget, State) 91 | Protected *gadget.GADGET=IsGadget(Gadget) 92 | If State 93 | *gadget\VT=*manager\NewVT 94 | Else 95 | *gadget\VT=*manager\OldVT 96 | EndIf 97 | EndProcedure 98 | Procedure ManageGadget(*manager.GADGET_MANAGER, Gadget, *params, GadgetType) 99 | Protected *gadget.GADGET=IsGadget(Gadget) 100 | With *manager 101 | If \OldVT=#Null And \NewVT=#Null 102 | ; define manager: custom events, custom VT, custom gadget type 103 | \OldVT=*gadget\VT 104 | \NewVT=AllocateMemory(SizeOf(GADGET_VT)) 105 | CopyMemory(\OldVT, \NewVT, SizeOf(GADGET_VT)) 106 | \NewVT\GadgetType=GadgetType 107 | EndIf 108 | ; use custom PB commands 109 | ManageGadgetCommands(*manager, Gadget, #True) 110 | 111 | ; save gadget params and increment counter 112 | \GadgetParams(""+*gadget)=*params 113 | \GadgetCount+1 114 | EndWith 115 | EndProcedure 116 | Procedure UnmanageGadget(*manager.GADGET_MANAGER, Gadget) 117 | Protected *gadget.GADGET=IsGadget(Gadget) 118 | With *manager 119 | \GadgetCount-1 120 | Protected *params=*manager\GadgetParams() 121 | DeleteMapElement(*manager\GadgetParams(), ""+*Gadget) 122 | If *params 123 | FreeStructure(*params) 124 | EndIf 125 | EndWith 126 | EndProcedure 127 | EndModule 128 | ; IDE Options = PureBasic 5.31 (Windows - x64) 129 | ; CursorPosition = 68 130 | ; FirstLine = 67 131 | ; Folding = - 132 | ; EnableUnicode 133 | ; EnableXP -------------------------------------------------------------------------------- /Includes/D3docker/Data/Close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Close.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Bottom.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Left.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Right.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Root_Bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Root_Bottom.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Root_Inside.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Root_Inside.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Root_Left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Root_Left.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Root_Right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Root_Right.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Root_Top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Root_Top.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Tabbed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Tabbed.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Diamond_Top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Diamond_Top.png -------------------------------------------------------------------------------- /Includes/D3docker/Data/Undock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Includes/D3docker/Data/Undock.png -------------------------------------------------------------------------------- /Includes/Helper.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; 28 | ; ################################################################################################################### 29 | ; ##################################################### Public ###################################################### 30 | ; ################################################################################################################### 31 | 32 | DeclareModule Helper 33 | EnableExplicit 34 | ; ################################################### Constants ################################################### 35 | 36 | ; ################################################### Macros ###################################################### 37 | Macro Line(x, y, Width, Height, Color) 38 | LineXY((x), (y), (x)+(Width), (y)+(Height), (Color)) 39 | EndMacro 40 | 41 | ; ################################################### Functions ################################################### 42 | Declare.s SHGetFolderPath(CSIDL) 43 | 44 | Declare.q Quad_Divide_Floor(A.q, B.q) 45 | Declare.q Quad_Divide_Ceil(A.q, B.q) 46 | 47 | EndDeclareModule 48 | 49 | ; ################################################################################################################### 50 | ; ##################################################### Private ##################################################### 51 | ; ################################################################################################################### 52 | 53 | Module Helper 54 | 55 | ; ################################################### Structures ################################################## 56 | 57 | 58 | 59 | 60 | ; ################################################### Procedures ################################################## 61 | Procedure.s SHGetFolderPath(CSIDL) 62 | Protected *String = AllocateMemory(#MAX_PATH+1) 63 | SHGetFolderPath_(0, CSIDL, #Null, 0, *String) 64 | Protected String.s = PeekS(*String) 65 | FreeMemory(*String) 66 | ProcedureReturn String 67 | EndProcedure 68 | 69 | ; #### Works perfectly, A and B can be positive or negative. B must not be zero! 70 | Procedure.q Quad_Divide_Floor(A.q, B.q) 71 | Protected Temp.q = A / B 72 | If (((a ! b) < 0) And (a % b <> 0)) 73 | ProcedureReturn Temp - 1 74 | Else 75 | ProcedureReturn Temp 76 | EndIf 77 | EndProcedure 78 | 79 | ; #### Works perfectly, A and B can be positive or negative. B must not be zero! 80 | Procedure.q Quad_Divide_Ceil(A.q, B.q) 81 | Protected Temp.q = A / B 82 | If (((a ! b) >= 0) And (a % b <> 0)) 83 | ProcedureReturn Temp + 1 84 | Else 85 | ProcedureReturn Temp 86 | EndIf 87 | EndProcedure 88 | 89 | EndModule 90 | 91 | ; IDE Options = PureBasic 5.31 (Windows - x64) 92 | ; CursorPosition = 45 93 | ; FirstLine = 9 94 | ; Folding = - 95 | ; EnableUnicode 96 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Icons.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; 28 | ; ################################################################################################################### 29 | ; ##################################################### Public ###################################################### 30 | ; ################################################################################################################### 31 | 32 | DeclareModule Icons 33 | EnableExplicit 34 | ; ################################################### Load Icons ################################################## 35 | Global Icon_New = CatchImage(#PB_Any, ?Icon_New) 36 | Global Icon_Save = CatchImage(#PB_Any, ?Icon_Save) 37 | Global Icon_SaveAs = CatchImage(#PB_Any, ?Icon_SaveAs) 38 | Global Icon_Open_File = CatchImage(#PB_Any, ?Icon_Open_File) 39 | Global Icon_Undo = CatchImage(#PB_Any, ?Icon_Undo) 40 | Global Icon_Redo = CatchImage(#PB_Any, ?Icon_Redo) 41 | Global Icon_Cut = CatchImage(#PB_Any, ?Icon_Cut) 42 | Global Icon_Copy = CatchImage(#PB_Any, ?Icon_Copy) 43 | Global Icon_Paste = CatchImage(#PB_Any, ?Icon_Paste) 44 | Global Icon_Select_All = CatchImage(#PB_Any, ?Icon_Select_All) 45 | Global Icon_Open_Process = CatchImage(#PB_Any, ?Icon_Open_Process) 46 | Global Icon_Open_Clipboard = CatchImage(#PB_Any, ?Icon_Open_Clipboard) 47 | Global Icon_Open_Random = CatchImage(#PB_Any, ?Icon_Open_Random) 48 | Global Icon_Open_Network_Terminal = CatchImage(#PB_Any, ?Icon_Open_Network_Terminal) 49 | Global Icon_Node_Editor = CatchImage(#PB_Any, ?Icon_Node_Editor) 50 | Global Icon_Node_Clear_Config = CatchImage(#PB_Any, ?Icon_Node_Clear_Config) 51 | Global Icon_Node_Load_Config = CatchImage(#PB_Any, ?Icon_Node_Load_Config) 52 | Global Icon_Node_Save_Config = CatchImage(#PB_Any, ?Icon_Node_Save_Config) 53 | Global Icon_Close = CatchImage(#PB_Any, ?Icon_Close) 54 | Global Icon_Resize = CatchImage(#PB_Any, ?Icon_Resize) 55 | Global Icon_Hilbert = CatchImage(#PB_Any, ?Icon_Hilbert) 56 | Global Icon_Gear = CatchImage(#PB_Any, ?Icon_Gear) 57 | Global Icon_Grid = CatchImage(#PB_Any, ?Icon_Grid) 58 | Global Icon_Search = CatchImage(#PB_Any, ?Icon_Search) 59 | Global Icon_Search_Continue = CatchImage(#PB_Any, ?Icon_Search_Continue) 60 | Global Icon_Goto = CatchImage(#PB_Any, ?Icon_Goto) 61 | Global Icon_Refresh = CatchImage(#PB_Any, ?Icon_Refresh) 62 | Global Icon_Automatic = CatchImage(#PB_Any, ?Icon_Automatic) 63 | 64 | ; ################################################### Data Sections ############################################### 65 | DataSection 66 | Icon_New: : IncludeBinary "../Data/Icons/New.png" 67 | Icon_Save: : IncludeBinary "../Data/Icons/Save.png" 68 | Icon_SaveAs: : IncludeBinary "../Data/Icons/SaveAs.png" 69 | Icon_Open_File: : IncludeBinary "../Data/Icons/Open_File.png" 70 | Icon_Undo: : IncludeBinary "../Data/Icons/Undo.png" 71 | Icon_Redo: : IncludeBinary "../Data/Icons/Redo.png" 72 | Icon_Cut: : IncludeBinary "../Data/Icons/Cut.png" 73 | Icon_Copy: : IncludeBinary "../Data/Icons/Copy.png" 74 | Icon_Paste: : IncludeBinary "../Data/Icons/Paste.png" 75 | Icon_Select_All: : IncludeBinary "../Data/Icons/Select_All.png" 76 | Icon_Open_Process: : IncludeBinary "../Data/Icons/Open_Process.png" 77 | Icon_Open_Clipboard: : IncludeBinary "../Data/Icons/Open_Clipboard.png" 78 | Icon_Open_Random: : IncludeBinary "../Data/Icons/Open_Random.png" 79 | Icon_Open_Network_Terminal: : IncludeBinary "../Data/Icons/Open_Network_Terminal.png" 80 | Icon_Node_Editor: : IncludeBinary "../Data/Icons/Node_Editor.png" 81 | Icon_Node_Clear_Config: : IncludeBinary "../Data/Icons/Node_Clear_Config.png" 82 | Icon_Node_Load_Config: : IncludeBinary "../Data/Icons/Node_Load_Config.png" 83 | Icon_Node_Save_Config: : IncludeBinary "../Data/Icons/Node_Save_Config.png" 84 | Icon_Close: : IncludeBinary "../Data/Icons/Close.png" 85 | Icon_Resize: : IncludeBinary "../Data/Icons/Resize.png" 86 | Icon_Hilbert: : IncludeBinary "../Data/Icons/Hilbert.png" 87 | Icon_Gear: : IncludeBinary "../Data/Icons/Gear.png" 88 | Icon_Grid: : IncludeBinary "../Data/Icons/Grid.png" 89 | Icon_Search: : IncludeBinary "../Data/Icons/Search.png" 90 | Icon_Search_Continue: : IncludeBinary "../Data/Icons/Search_Continue.png" 91 | Icon_Goto: : IncludeBinary "../Data/Icons/Goto.png" 92 | Icon_Refresh: : IncludeBinary "../Data/Icons/Refresh.png" 93 | Icon_Automatic: : IncludeBinary "../Data/Icons/Automatic.png" 94 | EndDataSection 95 | 96 | EndDeclareModule 97 | 98 | ; ################################################################################################################### 99 | ; ##################################################### Private ##################################################### 100 | ; ################################################################################################################### 101 | 102 | Module Icons 103 | 104 | EndModule 105 | 106 | ; IDE Options = PureBasic 5.31 (Windows - x64) 107 | ; CursorPosition = 93 108 | ; FirstLine = 56 109 | ; EnableUnicode 110 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Julia_API.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2016-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Documentation / Comments #################################### 20 | ; 21 | ; API between D3hex and Julia. 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ##################################################### Includes #################################################### 28 | 29 | ; ################################################################################################################### 30 | ; ##################################################### Public ###################################################### 31 | ; ################################################################################################################### 32 | 33 | DeclareModule Julia_API 34 | UseModule Julia 35 | 36 | EnableExplicit 37 | 38 | ; ################################################### Constants ################################################### 39 | #Linebreak = #CRLF$ 40 | 41 | ; ################################################### Structures ################################################## 42 | Structure Main 43 | Initialised.i 44 | EndStructure 45 | Global Main.Main 46 | 47 | Structure JL_Module 48 | *Helper.jl_value_t 49 | *PB.jl_value_t 50 | *Logger.jl_value_t 51 | *Node.jl_value_t 52 | EndStructure 53 | Global JL_Module.JL_Module 54 | 55 | ; ################################################### Prototypes ################################################## 56 | PrototypeC.i JL_GC_Ref(*Value.jl_value_t) 57 | PrototypeC.i JL_GC_Unref(*Value.jl_value_t) 58 | 59 | ; ################################################### Variables ################################################### 60 | Global JL_GC_Ref.JL_GC_Ref 61 | Global JL_GC_Unref.JL_GC_Unref 62 | 63 | ; ################################################### Functions ################################################### 64 | Declare.s JL_GetError(*Error.jl_value_t) 65 | 66 | Declare Init() 67 | Declare Deinit() 68 | 69 | EndDeclareModule 70 | 71 | ; ################################################################################################################### 72 | ; ##################################################### Private ##################################################### 73 | ; ################################################################################################################### 74 | 75 | Module Julia_API 76 | ; ################################################### Procedures ################################################## 77 | Procedure.s JL_GetError(*Error.jl_value_t) 78 | Protected *Result 79 | Protected *Function = jl_get_function(JL_Module\Helper, "GetError") 80 | 81 | *Result = jl_call1(*Function, *Error) 82 | If *Result And jl_array_data(*Result) 83 | ProcedureReturn PeekS(jl_array_data(*Result), jl_array_len(*Result), #PB_UTF8) 84 | EndIf 85 | 86 | ProcedureReturn "" 87 | EndProcedure 88 | 89 | ; ################################################### Procedures exported to Julia ################################ 90 | ProcedureC PB_Debug(Message.s) 91 | Debug "Julia-Debug: " + Message 92 | EndProcedure 93 | 94 | ProcedureC Logger_Entry_Add_Error(Name.s, Description.s) 95 | Logger::Entry_Add(Logger::#Entry_Type_Error, Name, Description, "Unknown", "Unknown", -1) 96 | EndProcedure 97 | 98 | ProcedureC Logger_Entry_Add_Warning(Name.s, Description.s) 99 | Logger::Entry_Add(Logger::#Entry_Type_Warning, Name, Description, "Unknown", "Unknown", -1) 100 | EndProcedure 101 | 102 | ; ################################################### Procedures to initialize Julia ############################## 103 | Procedure Register_Functions() 104 | Protected Temp_String.s 105 | 106 | ; #### Helper 107 | Temp_String = "module Helper" + #Linebreak 108 | 109 | Temp_String + "export gc_ref, gc_unref, GetError" + #Linebreak 110 | 111 | Temp_String + "function GetError(error)" + #Linebreak + 112 | " local stream = IOBuffer(true, true)" + #Linebreak + 113 | " showerror(stream, error)" + #Linebreak + 114 | ;~" write(stream, \"\nErrorObject: \")" + #Linebreak + 115 | ; " show(stream, error)" + #Linebreak + 116 | " seek(stream, 0)" + #Linebreak + 117 | " read(stream)" + #Linebreak + 118 | "end" + #Linebreak 119 | 120 | Temp_String + "const gc_preserve = ObjectIdDict() # reference counted closures" + #Linebreak 121 | Temp_String + "function gc_ref(x::ANY)" + #Linebreak + 122 | " global gc_preserve" + #Linebreak + 123 | ~" isbits(x) && error(\"can't gc-preserve an isbits object\")" + #Linebreak + 124 | " gc_preserve[x] = (get(gc_preserve, x, 0)::Int)+1" + #Linebreak + 125 | " x" + #Linebreak + 126 | "end" + #Linebreak 127 | Temp_String + "function gc_unref(x::ANY)" + #Linebreak + 128 | " global gc_preserve" + #Linebreak + 129 | " @assert !isbits(x)" + #Linebreak + 130 | " count = get(gc_preserve, x, 0)::Int-1" + #Linebreak + 131 | " if count <= 0" + #Linebreak + 132 | " delete!(gc_preserve, x)" + #Linebreak + 133 | " end" + #Linebreak + 134 | " nothing" + #Linebreak + 135 | "end" + #Linebreak 136 | Temp_String + "gc_ref_c = cfunction(gc_ref, Any, (Any,))" + #Linebreak 137 | Temp_String + "gc_unref_c = cfunction(gc_unref, Void, (Any,))" + #Linebreak 138 | 139 | Temp_String + "end" 140 | 141 | JL_Module\Helper = jl_eval_string(Temp_String) 142 | If jl_exception_occurred() 143 | Logger::Entry_Add_Error("Couldn't register Helper module in Julia", "jl_eval_string(Temp_String) failed: " + PeekS(jl_typeof_str(jl_exception_occurred()), -1, #PB_UTF8)) 144 | EndIf 145 | 146 | ; #### PureBasic 147 | Temp_String = "module PB" + #Linebreak 148 | 149 | Temp_String + "Debug(message::String) = ccall(convert(Ptr{Void}, "+Str(@PB_Debug())+"), Void, (Cwstring,), message)" + #Linebreak 150 | 151 | Temp_String + "end" 152 | 153 | JL_Module\PB = jl_eval_string(Temp_String) 154 | If jl_exception_occurred() 155 | Logger::Entry_Add_Error("Couldn't register PB module in Julia", "jl_eval_string(Temp_String) failed: " + JL_GetError(jl_exception_occurred())) 156 | EndIf 157 | 158 | ; #### Logger 159 | Temp_String = "module Logger" + #Linebreak 160 | 161 | Temp_String + "Entry_Add_Error(name::String, description::String) = ccall(convert(Ptr{Void}, "+Str(@Logger_Entry_Add_Error())+"), Void, (Cwstring,Cwstring), name, description)" + #Linebreak 162 | Temp_String + "Entry_Add_Warning(name::String, description::String) = ccall(convert(Ptr{Void}, "+Str(@Logger_Entry_Add_Warning())+"), Void, (Cwstring,Cwstring), name, description)" + #Linebreak 163 | 164 | Temp_String + "end" 165 | 166 | JL_Module\Logger = jl_eval_string(Temp_String) 167 | If jl_exception_occurred() 168 | Logger::Entry_Add_Error("Couldn't register Logger module in Julia", "jl_eval_string(Temp_String) failed: " + JL_GetError(jl_exception_occurred())) 169 | EndIf 170 | 171 | ; #### GC Preserve 172 | 173 | ; #### Retrieve gc_ref and gc_unref functions 174 | If JL_Module\Helper 175 | JL_GC_Ref = jl_unbox_voidpointer(jl_get_function(JL_Module\Helper, "gc_ref_c")) ; Not actually retrieving a jl_function here 176 | JL_GC_Unref = jl_unbox_voidpointer(jl_get_function(JL_Module\Helper, "gc_unref_c")) 177 | EndIf 178 | 179 | ; #### Node 180 | Temp_String = "module Node" + #Linebreak 181 | 182 | Temp_String + "const Event_Values = " + Node::#Event_Values + #Linebreak + 183 | #Linebreak + 184 | "const Event_Save = " + Node::#Event_Save + #Linebreak + 185 | "const Event_SaveAs = " + Node::#Event_SaveAs + #Linebreak + 186 | "const Event_Cut = " + Node::#Event_Cut + #Linebreak + 187 | "const Event_Copy = " + Node::#Event_Copy + #Linebreak + 188 | "const Event_Paste = " + Node::#Event_Paste + #Linebreak + 189 | "const Event_Undo = " + Node::#Event_Undo + #Linebreak + 190 | "const Event_Redo = " + Node::#Event_Redo + #Linebreak + 191 | "const Event_Goto = " + Node::#Event_Goto + #Linebreak + 192 | "const Event_Search = " + Node::#Event_Search + #Linebreak + 193 | "const Event_Search_Continue = " + Node::#Event_Search_Continue + #Linebreak + 194 | "const Event_Close = " + Node::#Event_Close + #Linebreak + 195 | #Linebreak + 196 | "const Link_Event_Update_Descriptor = " + Node::#Link_Event_Update_Descriptor + #Linebreak + 197 | "const Link_Event_Update = " + Node::#Link_Event_Update + #Linebreak + 198 | "const Link_Event_Goto = " + Node::#Link_Event_Goto + #Linebreak 199 | 200 | Temp_String + "type Object" + #Linebreak + 201 | "end" + #Linebreak 202 | 203 | Temp_String + "type Event" + #Linebreak + 204 | #Linebreak + 205 | " event_type::Int32" + #Linebreak + 206 | " position::Int64" + #Linebreak + 207 | " size::Int64" + #Linebreak + 208 | #Linebreak + 209 | " value::NTuple{Event_Values, Int64}" + #Linebreak + 210 | #Linebreak + 211 | " custom_data::Ptr{Void}" + #Linebreak + 212 | " function Event(event_type::Int64, position::Int64, size::Int64)" + #Linebreak + 213 | " event = new()" + #Linebreak + 214 | " event.event_type, event.position, event.size = Int32(event_type), position, size" + #Linebreak + 215 | " event" + #Linebreak + 216 | " end" + #Linebreak + 217 | "end" + #Linebreak + 218 | "@assert sizeof(Event) == " + SizeOf(Node::Event) + #Linebreak 219 | 220 | Temp_String + "type Conn_Input" + #Linebreak + 221 | "end" + #Linebreak 222 | 223 | Temp_String + "type Conn_Output" + #Linebreak + 224 | "end" + #Linebreak 225 | 226 | Temp_String + "Get(id::Int) = ccall(convert(Ptr{Void}, "+Str(Node::@Get())+"), Ptr{Object}, (Csize_t,), id)" + #Linebreak 227 | Temp_String + "Delete(node::Ptr{Object}) = ccall(convert(Ptr{Void}, "+Str(Node::@Delete())+"), Csize_t, (Ptr{Object},), node)" + #Linebreak 228 | Temp_String + "Event(node::Ptr{Object}, event::Ptr{Event}) = ccall(convert(Ptr{Void}, "+Str(Node::@Event())+"), Csize_t, (Ptr{Object}, Ptr{Event}), node, event)" + #Linebreak 229 | 230 | Temp_String + "Input_Get(node::Ptr{Object}, i::Int) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Get())+"), Ptr{Conn_Input}, (Ptr{Object}, Csize_t), node, i)" + #Linebreak 231 | Temp_String + "Input_Add(node::Ptr{Object}, name::String, short_name::String) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Add())+"), Ptr{Conn_Input}, (Ptr{Object}, Cwstring, Cwstring), node, name, short_name)" + #Linebreak 232 | Temp_String + "Input_Delete(node::Ptr{Object}, input::Ptr{Conn_Input}) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Delete())+"), Csize_t, (Ptr{Object}, Ptr{Conn_Input}), node, input)" + #Linebreak 233 | 234 | Temp_String + "Output_Get(node::Ptr{Object}, i::Int) = ccall(convert(Ptr{Void}, "+Str(Node::@Output_Get())+"), Ptr{Conn_Output}, (Ptr{Object}, Csize_t), node, i)" + #Linebreak 235 | Temp_String + "Output_Add(node::Ptr{Object}, name::String, short_name::String) = ccall(convert(Ptr{Void}, "+Str(Node::@Output_Add())+"), Ptr{Conn_Output}, (Ptr{Object}, Cwstring, Cwstring), node, name, short_name)" + #Linebreak 236 | Temp_String + "Output_Delete(node::Ptr{Object}, output::Ptr{Conn_Output}) = ccall(convert(Ptr{Void}, "+Str(Node::@Output_Delete())+"), Csize_t, (Ptr{Object}, Ptr{Conn_Output}), node, output)" + #Linebreak 237 | 238 | Temp_String + "Link_Disconnect(input::Ptr{Conn_Input}) = ccall(convert(Ptr{Void}, "+Str(Node::@Link_Disconnect())+"), Csize_t, (Ptr{Conn_Input},), input)" + #Linebreak 239 | Temp_String + "Link_Connect(output::Ptr{Conn_Output}, input::Ptr{Conn_Input}) = ccall(convert(Ptr{Void}, "+Str(Node::@Link_Connect())+"), Csize_t, (Ptr{Conn_Output}, Ptr{Conn_Input}), output, input)" + #Linebreak 240 | 241 | Temp_String + "Input_Event(input::Ptr{Conn_Input}, event::Ref{Event}) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Event())+"), Csize_t, (Ptr{Conn_Input}, Ref{Event}), input, event)" + #Linebreak 242 | Temp_String + "Input_Event(input::Ptr{Conn_Input}, event::Event) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Event())+"), Csize_t, (Ptr{Conn_Input}, Ref{Event}), input, event)" + #Linebreak 243 | Temp_String + "Output_Event(output::Ptr{Conn_Output}, event::Ref{Event}) = ccall(convert(Ptr{Void}, "+Str(Node::@Output_Event())+"), Csize_t, (Ptr{Conn_Output}, Ref{Event}), output, event)" + #Linebreak 244 | Temp_String + "Output_Event(output::Ptr{Conn_Output}, event::Event) = ccall(convert(Ptr{Void}, "+Str(Node::@Output_Event())+"), Csize_t, (Ptr{Conn_Output}, Ref{Event}), output, event)" + #Linebreak 245 | Temp_String + "Input_Get_Descriptor(input::Ptr{Conn_Input}) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Get_Descriptor())+"), Csize_t, (Ptr{Conn_Input},), input)" + #Linebreak 246 | ; TODO: Expose Input_Get_Segments to Julia 247 | Temp_String + "Input_Get_Size(input::Ptr{Conn_Input}) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Get_Size())+"), Int64, (Ptr{Conn_Input},), input)" + #Linebreak 248 | Temp_String + "function Input_Get_Data(input::Ptr{Conn_Input}, position::Int64, data::Array{UInt8,1}, metadata::Array{UInt8,1})" + #Linebreak + 249 | " size = min(sizeof(data), sizeof(metadata))" + #Linebreak + 250 | " ccall(convert(Ptr{Void}, "+Str(Node::@Input_Get_Data())+"), Csize_t, (Ptr{Conn_Input}, Int64, Csize_t, Ptr{Array{UInt8,1}}, Ptr{Array{UInt8,1}}), input, position, size, data, metadata)" + #Linebreak + 251 | "end"+ #Linebreak 252 | Temp_String + "function Input_Get_Data(input::Ptr{Conn_Input}, position::Int64, data::Array{UInt8,1})" + #Linebreak + 253 | " size = sizeof(data)" + #Linebreak + 254 | " ccall(convert(Ptr{Void}, "+Str(Node::@Input_Get_Data())+"), Csize_t, (Ptr{Conn_Input}, Int64, Csize_t, Ptr{Array{UInt8,1}}, Ptr{Array{UInt8,1}}), input, position, size, data, C_NULL)" + #Linebreak + 255 | "end"+ #Linebreak 256 | Temp_String + "function Input_Set_Data(input::Ptr{Conn_Input}, position::Int64, data::Array{UInt8,1})" + #Linebreak + 257 | " size = sizeof(data)" + #Linebreak + 258 | " ccall(convert(Ptr{Void}, "+Str(Node::@Input_Set_Data())+"), Csize_t, (Ptr{Conn_Input}, Int64, Csize_t, Ptr{Array{UInt8,1}}), input, position, size, data)" + #Linebreak + 259 | "end"+ #Linebreak 260 | Temp_String + "Input_Shift(input::Ptr{Conn_Input}, position::Int64, offset::Int64) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Shift())+"), Csize_t, (Ptr{Conn_Input}, Int64, Int64), input, position, offset)" + #Linebreak 261 | Temp_String + "Input_Set_Data_Check(input::Ptr{Conn_Input}, position::Int64, size::Csize_t) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Set_Data_Check())+"), Csize_t, (Ptr{Conn_Input}, Int64, Csize_t), input, position, size)" + #Linebreak 262 | Temp_String + "Input_Shift_Check(input::Ptr{Conn_Input}, position::Int64, offset::Int64) = ccall(convert(Ptr{Void}, "+Str(Node::@Input_Shift_Check())+"), Csize_t, (Ptr{Conn_Input}, Int64, Int64), input, position, offset)" + #Linebreak 263 | 264 | Temp_String + "end" 265 | 266 | JL_Module\Node = jl_eval_string(Temp_String) 267 | If jl_exception_occurred() 268 | Logger::Entry_Add_Error("Couldn't register Node module in Julia", "jl_eval_string(Temp_String) failed: " + JL_GetError(jl_exception_occurred())) 269 | EndIf 270 | 271 | ProcedureReturn #True 272 | EndProcedure 273 | 274 | Procedure Init() 275 | ; #### Check if the library is loaded 276 | If Not IsLibrary(Julia::_JL_Library_ID) 277 | Main\Initialised = #False 278 | ProcedureReturn #False 279 | EndIf 280 | 281 | ; #### Init Julia 282 | If jl_init(#Null) 283 | Main\Initialised = #True 284 | Else 285 | Logger::Entry_Add_Error("Couldn't initialize Julia", "jl_init(#Null) failed.") 286 | Main\Initialised = #False 287 | ProcedureReturn #False 288 | EndIf 289 | 290 | ; #### Register D3hex functions inside Julia 291 | ProcedureReturn Register_Functions() 292 | EndProcedure 293 | 294 | Procedure Deinit() 295 | If Not Main\Initialised 296 | ProcedureReturn #True 297 | EndIf 298 | Main\Initialised = #False 299 | 300 | If IsLibrary(Julia::_JL_Library_ID) 301 | jl_atexit_hook(0) 302 | EndIf 303 | 304 | ProcedureReturn #True 305 | EndProcedure 306 | 307 | EndModule 308 | 309 | ; IDE Options = PureBasic 5.42 LTS (Windows - x64) 310 | ; CursorPosition = 114 311 | ; FirstLine = 91 312 | ; Folding = -- 313 | ; EnableUnicode 314 | ; EnableXP 315 | ; EnableCompileCount = 0 316 | ; EnableBuildCount = 0 317 | ; EnableExeConstant -------------------------------------------------------------------------------- /Includes/Logger.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation ############################################### 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ##################################################### Includes #################################################### 28 | 29 | ; ################################################################################################################### 30 | ; ##################################################### Public ###################################################### 31 | ; ################################################################################################################### 32 | 33 | DeclareModule Logger 34 | EnableExplicit 35 | 36 | ; ################################################### Constants ################################################### 37 | Enumeration 38 | #Entry_Type_Warning 39 | #Entry_Type_Error 40 | EndEnumeration 41 | 42 | ; ################################################### Functions ################################################### 43 | Declare Entry_Add(Type, Name.s, Description.s, Include.s, Function.s, Line.l) 44 | 45 | Declare Init(Parent_Window.i) 46 | Declare Main() 47 | 48 | ; ################################################### Macros ###################################################### 49 | Macro Entry_Add_Error(Name, Description) 50 | Logger::Entry_Add(Logger::#Entry_Type_Error, Name, Description, #PB_Compiler_Filename, #PB_Compiler_Procedure, #PB_Compiler_Line) 51 | EndMacro 52 | 53 | Macro Entry_Add_Warning(Name, Description) 54 | Logger::Entry_Add(Logger::#Entry_Type_Warning, Name, Description, #PB_Compiler_Filename, #PB_Compiler_Procedure, #PB_Compiler_Line) 55 | EndMacro 56 | 57 | EndDeclareModule 58 | 59 | ; ################################################################################################################### 60 | ; ##################################################### Private ##################################################### 61 | ; ################################################################################################################### 62 | 63 | Module Logger 64 | ; ################################################### Structures ################################################## 65 | Structure Main 66 | 67 | Parent_Window.i 68 | 69 | Open_Window_Window.l 70 | 71 | EndStructure 72 | Global Main.Main 73 | 74 | Structure Entry 75 | Type.i 76 | 77 | Name.s 78 | Description.s 79 | 80 | Shown.l 81 | 82 | ; #### Place 83 | Include.s 84 | Function.s 85 | Line.l 86 | EndStructure 87 | Global NewList Entry.Entry() 88 | 89 | Structure Window 90 | ID.i 91 | Close.l 92 | 93 | ; #### Gadgets 94 | Image.i 95 | Text.i[10] 96 | Editor.i 97 | EndStructure 98 | Global Window.Window 99 | 100 | ; ################################################### Init ######################################################## 101 | Global Icon_Error = CatchImage(#PB_Any, ?Icon_Error) 102 | Global Icon_Warning = CatchImage(#PB_Any, ?Icon_Warning) 103 | 104 | Global Window_Font_Big = LoadFont(#PB_Any, "Courier New", 15) 105 | Global Window_Font_Small = LoadFont(#PB_Any, "Courier New", 10) 106 | 107 | ; ################################################### Declares #################################################### 108 | Declare Window_Close() 109 | 110 | ; ################################################### Procedures ################################################## 111 | Procedure Entry_Add(Type, Name.s, Description.s, Include.s, Function.s, Line.l) 112 | LastElement(Entry()) 113 | If AddElement(Entry()) 114 | 115 | Select Type 116 | Case #Entry_Type_Error 117 | Main\Open_Window_Window = #True 118 | EndSelect 119 | 120 | Entry()\Type = Type 121 | Entry()\Name = Name 122 | Entry()\Description = Description 123 | Entry()\Include = Include 124 | Entry()\Function = Function 125 | Entry()\Line = Line 126 | 127 | ProcedureReturn #True 128 | EndIf 129 | 130 | ProcedureReturn #False 131 | EndProcedure 132 | 133 | Procedure Window_Fill() 134 | 135 | SetGadgetState(Window\Image, ImageID(Icon_Error)) 136 | 137 | ForEach Entry() 138 | If Not Entry()\Shown 139 | SetGadgetText(Window\Text[0], Entry()\Name) 140 | SetGadgetText(Window\Text[1], Entry()\Description) 141 | Break 142 | EndIf 143 | Next 144 | 145 | 146 | ; #### Fill in last errors 147 | ClearGadgetItems(Window\Editor) 148 | SetGadgetFont(Window\Editor, FontID(Window_Font_Small)) 149 | 150 | ForEach Entry() 151 | If Not Entry()\Shown 152 | AddGadgetItem(Window\Editor, -1, "Name: "+Entry()\Name) 153 | AddGadgetItem(Window\Editor, -1, "Description: "+Entry()\Description) 154 | AddGadgetItem(Window\Editor, -1, "Place: "+Entry()\Include+":"+Entry()\Function+":"+Str(Entry()\Line)) 155 | AddGadgetItem(Window\Editor, -1, "") 156 | AddGadgetItem(Window\Editor, -1, "########################################") 157 | AddGadgetItem(Window\Editor, -1, "") 158 | EndIf 159 | Next 160 | 161 | EndProcedure 162 | 163 | Procedure Window_Event_SizeWindow() 164 | Protected Event_Window = EventWindow() 165 | 166 | EndProcedure 167 | 168 | Procedure Window_Event_ActivateWindow() 169 | Protected Event_Window = EventWindow() 170 | Protected Event_Gadget = EventGadget() 171 | Protected Event_Type = EventType() 172 | 173 | EndProcedure 174 | 175 | Procedure Window_Event_Menu() 176 | Protected Event_Window = EventWindow() 177 | Protected Event_Gadget = EventGadget() 178 | Protected Event_Type = EventType() 179 | Protected Event_Menu = EventMenu() 180 | 181 | EndProcedure 182 | 183 | Procedure Window_Event_CloseWindow() 184 | Protected Event_Window = EventWindow() 185 | Protected Event_Gadget = EventGadget() 186 | Protected Event_Type = EventType() 187 | 188 | ;Window_Close() 189 | Window\Close = #True 190 | EndProcedure 191 | 192 | Procedure Window_Open() 193 | Protected Width, Height 194 | 195 | If Window\ID = 0 196 | 197 | Width = 500 198 | Height = 250 199 | 200 | Window\ID = OpenWindow(#PB_Any, 0, 0, Width, Height, "Error", #PB_Window_SystemMenu | #PB_Window_WindowCentered, WindowID(Main\Parent_Window)) 201 | 202 | Window\Image = ImageGadget(#PB_Any, 10, 10, 32, 32, 0) 203 | Window\Text[0] = TextGadget(#PB_Any, 50, 00, Width-50, 30, "No Error") 204 | Window\Text[1] = TextGadget(#PB_Any, 50, 30, Width-50, 60, "-") 205 | Window\Editor = EditorGadget(#PB_Any, 0, 90, Width, Height-90, #PB_Editor_ReadOnly) 206 | 207 | SetGadgetFont(Window\Text[0], FontID(Window_Font_Big)) 208 | SetGadgetFont(Window\Text[1], FontID(Window_Font_Small)) 209 | 210 | Window_Fill() 211 | 212 | BindEvent(#PB_Event_SizeWindow, @Window_Event_SizeWindow(), Window\ID) 213 | ;BindEvent(#PB_Event_Repaint, @Window_Event_SizeWindow(), Window\ID) 214 | ;BindEvent(#PB_Event_RestoreWindow, @Window_Event_SizeWindow(), Window\ID) 215 | BindEvent(#PB_Event_Menu, @Window_Event_Menu(), Window\ID) 216 | BindEvent(#PB_Event_CloseWindow, @Window_Event_CloseWindow(), Window\ID) 217 | 218 | Else 219 | Window_Fill() 220 | EndIf 221 | EndProcedure 222 | 223 | Procedure Window_Close() 224 | If Window\ID 225 | 226 | UnbindEvent(#PB_Event_SizeWindow, @Window_Event_SizeWindow(), Window\ID) 227 | ;UnbindEvent(#PB_Event_Repaint, @Window_Event_SizeWindow(), Window\ID) 228 | ;UnbindEvent(#PB_Event_RestoreWindow, @Window_Event_SizeWindow(), Window\ID) 229 | UnbindEvent(#PB_Event_Menu, @Window_Event_Menu(), Window\ID) 230 | UnbindEvent(#PB_Event_CloseWindow, @Window_Event_CloseWindow(), Window\ID) 231 | 232 | CloseWindow(Window\ID) 233 | Window\ID = 0 234 | 235 | ForEach Entry() 236 | If Not Entry()\Shown 237 | Entry()\Shown = #True 238 | EndIf 239 | Next 240 | 241 | EndIf 242 | EndProcedure 243 | 244 | Procedure Init(Parent_Window.i) 245 | Main\Parent_Window = Parent_Window 246 | EndProcedure 247 | 248 | Procedure Main() 249 | If Main\Open_Window_Window 250 | Main\Open_Window_Window = #False 251 | Window_Open() 252 | EndIf 253 | 254 | If Window\Close 255 | Window\Close = #False 256 | Window_Close() 257 | EndIf 258 | EndProcedure 259 | 260 | ; ################################################### Data Sections ############################################### 261 | DataSection 262 | Icon_Error: 263 | IncludeBinary "../Data/Icons/Error.png" 264 | Icon_Warning: 265 | IncludeBinary "../Data/Icons/Warning.png" 266 | EndDataSection 267 | 268 | EndModule 269 | ; IDE Options = PureBasic 5.31 (Windows - x64) 270 | ; CursorPosition = 184 271 | ; FirstLine = 156 272 | ; Folding = --- 273 | ; EnableUnicode 274 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Memory.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Documentation ############################################### 20 | ; 21 | ; 22 | ; ##################################################### Includes #################################################### 23 | 24 | ; ################################################################################################################### 25 | ; ##################################################### Public ###################################################### 26 | ; ################################################################################################################### 27 | 28 | DeclareModule Memory 29 | EnableExplicit 30 | ; ################################################### Constants ################################################### 31 | 32 | ; ################################################### Structures ################################################## 33 | Structure Operation 34 | Src_Offset.q 35 | Src_Size.q 36 | 37 | Dst_Offset.q 38 | Dst_Size.q 39 | 40 | Copy_Size.q 41 | EndStructure 42 | 43 | ; ################################################### Functions ################################################### 44 | Declare Operation_Check(*Operation.Operation) 45 | Declare Range_Fill(Ascii.a, Fill_Size.q, *Dst, Dst_Offset.q, Dst_Size.q=-1) 46 | Declare Range_Copy(*Src, Src_Offset.q, *Dst, Dst_Offset.q, Copy_Size.q, Src_Size.q=-1, Dst_Size.q=-1) 47 | Declare Range_Move(*Src, Src_Offset.q, *Dst, Dst_Offset.q, Copy_Size.q, Src_Size.q=-1, Dst_Size.q=-1) 48 | Declare Mirror(*Memory, Size) 49 | 50 | EndDeclareModule 51 | 52 | ; ################################################################################################################### 53 | ; ##################################################### Private ##################################################### 54 | ; ################################################################################################################### 55 | 56 | Module Memory 57 | ; ################################################### Functions ################################################### 58 | 59 | ; #### Cuts the Offset's / Sizes of the memory operation to prevent memory violations 60 | Procedure Operation_Check(*Operation.Operation) 61 | Protected Temp.q 62 | 63 | If *Operation\Src_Offset < 0 64 | *Operation\Copy_Size + *Operation\Src_Offset 65 | *Operation\Dst_Offset - *Operation\Src_Offset 66 | *Operation\Src_Offset - *Operation\Src_Offset 67 | EndIf 68 | 69 | If *Operation\Dst_Offset < 0 70 | *Operation\Copy_Size + *Operation\Dst_Offset 71 | *Operation\Src_Offset - *Operation\Dst_Offset 72 | *Operation\Dst_Offset - *Operation\Dst_Offset 73 | EndIf 74 | 75 | Temp = *Operation\Src_Size - *Operation\Src_Offset 76 | If *Operation\Copy_Size > Temp 77 | *Operation\Copy_Size = Temp 78 | EndIf 79 | 80 | Temp = *Operation\Dst_Size - *Operation\Dst_Offset 81 | If *Operation\Copy_Size > Temp 82 | *Operation\Copy_Size = Temp 83 | EndIf 84 | 85 | If *Operation\Copy_Size < 0 86 | *Operation\Copy_Size = 0 87 | EndIf 88 | 89 | ProcedureReturn #True 90 | EndProcedure 91 | 92 | ; #### Fills a *Destination with a specified amount of data. 93 | ; #### It cuts everything, to prevent memory violations 94 | Procedure Range_Fill(Ascii.a, Fill_Size.q, *Dst, Dst_Offset.q, Dst_Size.q=-1) 95 | Protected Temp.q 96 | 97 | If Not *Dst 98 | ProcedureReturn #False 99 | EndIf 100 | 101 | If Dst_Size = -1 102 | Dst_Size.q = MemorySize(*Dst) 103 | EndIf 104 | 105 | If Dst_Offset < 0 106 | Fill_Size + Dst_Offset 107 | Dst_Offset - Dst_Offset 108 | EndIf 109 | 110 | Temp = Dst_Size - Dst_Offset 111 | If Fill_Size > Temp 112 | Fill_Size = Temp 113 | EndIf 114 | 115 | If Fill_Size > 0 116 | FillMemory(*Dst+Dst_Offset, Fill_Size, Ascii) 117 | EndIf 118 | 119 | ProcedureReturn #True 120 | EndProcedure 121 | 122 | ; #### Copies a specified amount of data (Copy_Size) from the source to the destination. 123 | ; #### It cuts everything, to prevent memory violations 124 | Procedure Range_Copy(*Src, Src_Offset.q, *Dst, Dst_Offset.q, Copy_Size.q, Src_Size.q=-1, Dst_Size.q=-1) 125 | Protected Temp.q 126 | If Not *Src 127 | ProcedureReturn #False 128 | EndIf 129 | 130 | If Not *Dst 131 | ProcedureReturn #False 132 | EndIf 133 | 134 | If Src_Size = -1 135 | Src_Size.q = MemorySize(*Src) 136 | EndIf 137 | If Dst_Size = -1 138 | Dst_Size.q = MemorySize(*Dst) 139 | EndIf 140 | 141 | If Src_Offset < 0 142 | Copy_Size + Src_Offset 143 | Dst_Offset - Src_Offset 144 | Src_Offset - Src_Offset 145 | EndIf 146 | 147 | If Dst_Offset < 0 148 | Copy_Size + Dst_Offset 149 | Src_Offset - Dst_Offset 150 | Dst_Offset - Dst_Offset 151 | EndIf 152 | 153 | Temp = Src_Size - Src_Offset 154 | If Copy_Size > Temp 155 | Copy_Size = Temp 156 | EndIf 157 | 158 | Temp = Dst_Size - Dst_Offset 159 | If Copy_Size > Temp 160 | Copy_Size = Temp 161 | EndIf 162 | 163 | If Copy_Size > 0 164 | CopyMemory(*Src+Src_Offset, *Dst+Dst_Offset, Copy_Size) 165 | EndIf 166 | 167 | ProcedureReturn #True 168 | EndProcedure 169 | 170 | ; #### Copies (MoveMemory) a specified amount of data (Copy_Size) from the source to the destination. 171 | ; #### It cuts everything, to prevent memory violations 172 | Procedure Range_Move(*Src, Src_Offset.q, *Dst, Dst_Offset.q, Copy_Size.q, Src_Size.q=-1, Dst_Size.q=-1) 173 | Protected Temp.q 174 | If Not *Src 175 | ProcedureReturn #False 176 | EndIf 177 | 178 | If Not *Dst 179 | ProcedureReturn #False 180 | EndIf 181 | 182 | If Src_Size = -1 183 | Src_Size.q = MemorySize(*Src) 184 | EndIf 185 | If Dst_Size = -1 186 | Dst_Size.q = MemorySize(*Dst) 187 | EndIf 188 | 189 | If Src_Offset < 0 190 | Copy_Size + Src_Offset 191 | Dst_Offset - Src_Offset 192 | Src_Offset - Src_Offset 193 | EndIf 194 | 195 | If Dst_Offset < 0 196 | Copy_Size + Dst_Offset 197 | Src_Offset - Dst_Offset 198 | Dst_Offset - Dst_Offset 199 | EndIf 200 | 201 | Temp = Src_Size - Src_Offset 202 | If Copy_Size > Temp 203 | Copy_Size = Temp 204 | EndIf 205 | 206 | Temp = Dst_Size - Dst_Offset 207 | If Copy_Size > Temp 208 | Copy_Size = Temp 209 | EndIf 210 | 211 | If Copy_Size > 0 212 | MoveMemory(*Src+Src_Offset, *Dst+Dst_Offset, Copy_Size) 213 | EndIf 214 | 215 | ProcedureReturn #True 216 | EndProcedure 217 | 218 | ; #### Mirrors the memory, usable for little/big endian switching 219 | Procedure Mirror(*Memory, Size) 220 | Protected Elements, i 221 | Protected Temp.a, *A.Ascii, *B.Ascii 222 | 223 | If Not *Memory 224 | ProcedureReturn #False 225 | EndIf 226 | 227 | If Size < 1 228 | ProcedureReturn #True 229 | EndIf 230 | 231 | Elements = Size/2 232 | *A = *Memory 233 | *B = *Memory + Size - 1 234 | 235 | For i = 0 To Elements - 1 236 | Temp = *A\a 237 | *A\a = *B\a 238 | *B\a = Temp 239 | *A + 1 240 | *B - 1 241 | Next 242 | 243 | ProcedureReturn #True 244 | EndProcedure 245 | EndModule 246 | 247 | ; IDE Options = PureBasic 5.31 (Windows - x64) 248 | ; CursorPosition = 246 249 | ; FirstLine = 201 250 | ; Folding = - 251 | ; EnableXP 252 | ; DisableDebugger -------------------------------------------------------------------------------- /Includes/Node_Type.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ##################################################### Includes #################################################### 28 | 29 | ; ################################################################################################################### 30 | ; ##################################################### Public ###################################################### 31 | ; ################################################################################################################### 32 | 33 | DeclareModule Node_Type 34 | EnableExplicit 35 | ; ################################################### Prototypes ################################################## 36 | Prototype Function_Create(Requester) 37 | 38 | ; ################################################### Constants ################################################### 39 | 40 | ; ################################################### Structures ################################################## 41 | Structure Object 42 | ID.i 43 | 44 | UID.s {8} 45 | 46 | Name.s 47 | Description.s 48 | Category.s 49 | Author.s 50 | Date_Creation.q 51 | Date_Modification.q 52 | Date_Compilation.q 53 | Version.l 54 | 55 | Function_Create.Function_Create 56 | EndStructure 57 | Global NewList Object.Object() 58 | 59 | ; ################################################### Functions ################################################### 60 | Declare Get_UID(UID.s) 61 | Declare Get(ID.i) 62 | Declare Create() 63 | Declare Delete(*Object_Type.Object) 64 | 65 | EndDeclareModule 66 | 67 | ; ################################################################################################################### 68 | ; ##################################################### Private ##################################################### 69 | ; ################################################################################################################### 70 | 71 | Module Node_Type 72 | ; ################################################### Structures ################################################## 73 | Structure Main 74 | ID_Counter.i 75 | EndStructure 76 | Global Main.Main 77 | 78 | ; ################################################### Procedures ################################################## 79 | Procedure Get_UID(UID.s) 80 | Protected *Result.Object = #Null 81 | 82 | PushListPosition(Object()) 83 | 84 | ForEach Object() 85 | If Object()\UID = UID 86 | *Result = Object() 87 | Break 88 | EndIf 89 | Next 90 | 91 | PopListPosition(Object()) 92 | 93 | ProcedureReturn *Result 94 | EndProcedure 95 | 96 | Procedure Get(ID.i) 97 | Protected *Result.Object = #Null 98 | 99 | PushListPosition(Object()) 100 | 101 | ForEach Object() 102 | If Object()\ID = ID 103 | *Result = Object() 104 | Break 105 | EndIf 106 | Next 107 | 108 | PopListPosition(Object()) 109 | 110 | ProcedureReturn *Result 111 | EndProcedure 112 | 113 | Procedure Create() 114 | If Not AddElement(Object()) 115 | ProcedureReturn #Null 116 | EndIf 117 | 118 | Object()\Name = "Empty" 119 | Main\ID_Counter + 1 120 | Object()\ID = Main\ID_Counter 121 | 122 | ProcedureReturn Object() 123 | EndProcedure 124 | 125 | Procedure Delete(*Object_Type.Object) 126 | If Not *Object_Type 127 | ProcedureReturn #False 128 | EndIf 129 | 130 | If ChangeCurrentElement(Object(), *Object_Type) 131 | DeleteElement(Object()) 132 | EndIf 133 | 134 | ProcedureReturn #True 135 | EndProcedure 136 | 137 | EndModule 138 | 139 | ; IDE Options = PureBasic 5.31 (Windows - x64) 140 | ; CursorPosition = 120 141 | ; FirstLine = 93 142 | ; Folding = - 143 | ; EnableUnicode 144 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Nodes/Dummy/Dummy.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; TODO: Get_Descriptor(...) 26 | ; 27 | ; ################################################################################################################### 28 | ; ##################################################### Public ###################################################### 29 | ; ################################################################################################################### 30 | 31 | DeclareModule _Node_Dummy 32 | EnableExplicit 33 | 34 | ; ################################################### Functions ################################################### 35 | Declare Create(Requester) 36 | 37 | EndDeclareModule 38 | 39 | ; ################################################################################################################### 40 | ; ##################################################### Private ##################################################### 41 | ; ################################################################################################################### 42 | 43 | Module _Node_Dummy 44 | ; ################################################### Includes #################################################### 45 | UseModule Constants 46 | UseModule Helper 47 | 48 | ; ################################################### Prototypes ################################################## 49 | 50 | ; ################################################### Structures ################################################## 51 | 52 | ; ################################################### Constants ################################################### 53 | 54 | #MemoryAllocation_Step = 1024*1024*1 55 | 56 | ; ################################################### Structures ################################################## 57 | 58 | Structure Main 59 | *Node_Type.Node_Type::Object 60 | EndStructure 61 | Global Main.Main 62 | 63 | Structure Object 64 | *Raw_Data 65 | Raw_Data_Size.i 66 | EndStructure 67 | 68 | ; ################################################### Variables ################################################### 69 | 70 | ; ################################################### Declares #################################################### 71 | 72 | Declare _Delete(*Node.Node::Object) 73 | 74 | Declare Configuration_Get(*Node.Node::Object, *Parent_Tag.NBT::Tag) 75 | Declare Configuration_Set(*Node.Node::Object, *Parent_Tag.NBT::Tag) 76 | 77 | Declare Get_Descriptor(*Output.Node::Conn_Output) 78 | Declare.q Get_Size(*Output.Node::Conn_Output) 79 | Declare Get_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data, *Metadata) 80 | Declare Set_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data) 81 | Declare Shift(*Output.Node::Conn_Output, Position.q, Offset.q) 82 | 83 | ; ################################################### Procedures ################################################## 84 | 85 | Procedure Create(Requester) 86 | Protected *Node.Node::Object = Node::_Create() 87 | Protected *Object.Object 88 | Protected *Output.Node::Conn_Output 89 | 90 | If Not *Node 91 | ProcedureReturn #Null 92 | EndIf 93 | 94 | *Node\Type = Main\Node_Type 95 | *Node\Type_Base = Main\Node_Type 96 | 97 | *Node\Function_Delete = @_Delete() 98 | *Node\Function_Configuration_Get = @Configuration_Get() 99 | *Node\Function_Configuration_Set = @Configuration_Set() 100 | 101 | *Node\Name = Main\Node_Type\Name 102 | *Node\Name_Inherited = *Node\Name 103 | *Node\Color = RGBA(127, 127, 100, 255) 104 | 105 | *Node\Custom_Data = AllocateStructure(Object) 106 | *Object = *Node\Custom_Data 107 | 108 | *Object\Raw_Data = AllocateMemory(#MemoryAllocation_Step) 109 | 110 | ; #### Add Output 111 | *Output = Node::Output_Add(*Node) 112 | *Output\Function_Get_Descriptor = @Get_Descriptor() 113 | *Output\Function_Get_Size = @Get_Size() 114 | *Output\Function_Get_Data = @Get_Data() 115 | *Output\Function_Set_Data = @Set_Data() 116 | *Output\Function_Shift = @Shift() 117 | 118 | 119 | ; #### Debugdata 120 | ;Protected *Temp = AllocateMemory(1000000) 121 | ;Protected i 122 | 123 | ;For i = 0 To 1000000-1 Step 8 124 | ; PokeD(*Temp + i, Sin(i/8/1000*2*#PI)*1000) 125 | ;Next 126 | 127 | ;Set_Data(*Output, 0, 1000000, *Temp) 128 | 129 | ;FreeMemory(*Temp) 130 | 131 | ProcedureReturn *Node 132 | EndProcedure 133 | 134 | Procedure _Delete(*Node.Node::Object) 135 | If Not *Node 136 | ProcedureReturn #False 137 | EndIf 138 | 139 | Protected *Object.Object = *Node\Custom_Data 140 | If Not *Object 141 | ProcedureReturn #False 142 | EndIf 143 | 144 | If *Object\Raw_Data 145 | FreeMemory(*Object\Raw_Data) 146 | EndIf 147 | 148 | FreeStructure(*Object) 149 | *Node\Custom_Data = #Null 150 | 151 | ProcedureReturn #True 152 | EndProcedure 153 | 154 | Procedure Configuration_Get(*Node.Node::Object, *Parent_Tag.NBT::Tag) 155 | Protected *NBT_Tag.NBT::Tag 156 | 157 | If Not *Node 158 | ProcedureReturn #False 159 | EndIf 160 | Protected *Object.Object = *Node\Custom_Data 161 | If Not *Object 162 | ProcedureReturn #False 163 | EndIf 164 | If Not *Parent_Tag 165 | ProcedureReturn #False 166 | EndIf 167 | 168 | *NBT_Tag = NBT::Tag_Add(*Parent_Tag, "Data", NBT::#Tag_Byte_Array) : NBT::Tag_Set_Array(*NBT_Tag, *Object\Raw_Data, *Object\Raw_Data_Size) 169 | 170 | ProcedureReturn #True 171 | EndProcedure 172 | 173 | Procedure Configuration_Set(*Node.Node::Object, *Parent_Tag.NBT::Tag) 174 | Protected *NBT_Tag.NBT::Tag 175 | Protected New_Size.i, *Temp 176 | 177 | If Not *Node 178 | ProcedureReturn #False 179 | EndIf 180 | Protected *Object.Object = *Node\Custom_Data 181 | If Not *Object 182 | ProcedureReturn #False 183 | EndIf 184 | If Not *Parent_Tag 185 | ProcedureReturn #False 186 | EndIf 187 | 188 | *NBT_Tag = NBT::Tag(*Parent_Tag, "Data") 189 | 190 | ; #### Reallocate Memory 191 | *Object\Raw_Data_Size = NBT::Tag_Count(*NBT_Tag) 192 | New_Size = Quad_Divide_Ceil(*Object\Raw_Data_Size, #MemoryAllocation_Step) * #MemoryAllocation_Step 193 | If New_Size <> MemorySize(*Object\Raw_Data) And New_Size > 0 194 | *Temp = ReAllocateMemory(*Object\Raw_Data, New_Size) 195 | If *Temp 196 | *Object\Raw_Data = *Temp 197 | Else 198 | ProcedureReturn #False 199 | EndIf 200 | EndIf 201 | 202 | NBT::Tag_Get_Array(*NBT_Tag, *Object\Raw_Data, *Object\Raw_Data_Size) 203 | 204 | ProcedureReturn #True 205 | EndProcedure 206 | 207 | Procedure Get_Descriptor(*Output.Node::Conn_Output) 208 | If Not *Output 209 | ProcedureReturn #Null 210 | EndIf 211 | Protected *Node.Node::Object = *Output\Object 212 | If Not *Node 213 | ProcedureReturn #Null 214 | EndIf 215 | 216 | Protected *Object.Object = *Node\Custom_Data 217 | If Not *Object 218 | ProcedureReturn #Null 219 | EndIf 220 | 221 | NBT::Tag_Set_String(NBT::Tag_Add(*Output\Descriptor\Tag, "Name", NBT::#Tag_String), "Dummy") 222 | 223 | ProcedureReturn *Output\Descriptor 224 | EndProcedure 225 | 226 | Procedure.q Get_Size(*Output.Node::Conn_Output) 227 | If Not *Output 228 | ProcedureReturn -1 229 | EndIf 230 | Protected *Node.Node::Object = *Output\Object 231 | If Not *Node 232 | ProcedureReturn -1 233 | EndIf 234 | 235 | Protected *Object.Object = *Node\Custom_Data 236 | If Not *Object 237 | ProcedureReturn -1 238 | EndIf 239 | 240 | ProcedureReturn *Object\Raw_Data_Size 241 | EndProcedure 242 | 243 | Procedure Get_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data, *Metadata) 244 | If Not *Output 245 | ProcedureReturn #False 246 | EndIf 247 | Protected *Node.Node::Object = *Output\Object 248 | If Not *Node 249 | ProcedureReturn #False 250 | EndIf 251 | If Position < 0 252 | ProcedureReturn #False 253 | EndIf 254 | 255 | Protected *Object.Object = *Node\Custom_Data 256 | If Not *Object 257 | ProcedureReturn #False 258 | EndIf 259 | 260 | If Position > *Object\Raw_Data_Size 261 | ProcedureReturn #False 262 | EndIf 263 | If Size > *Object\Raw_Data_Size - Position 264 | Size = *Object\Raw_Data_Size - Position 265 | EndIf 266 | If Size <= 0 267 | ProcedureReturn #False 268 | EndIf 269 | 270 | If *Metadata 271 | FillMemory(*Metadata, Size, #Metadata_NoError | #Metadata_Readable | #Metadata_Writeable, #PB_Ascii) 272 | EndIf 273 | 274 | ProcedureReturn Memory::Range_Copy(*Object\Raw_Data, Position, *Data, 0, Size, *Object\Raw_Data_Size, Size) 275 | EndProcedure 276 | 277 | Procedure Set_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data) 278 | Protected Result.i 279 | Protected Event.Node::Event 280 | Protected Temp_Size.q, New_Size.i, *Temp 281 | 282 | If Not *Output 283 | ProcedureReturn #False 284 | EndIf 285 | Protected *Node.Node::Object = *Output\Object 286 | If Not *Node 287 | ProcedureReturn #False 288 | EndIf 289 | If Position < 0 290 | ProcedureReturn #False 291 | EndIf 292 | If Size <= 0 293 | ProcedureReturn #False 294 | EndIf 295 | Protected *Object.Object = *Node\Custom_Data 296 | If Not *Object 297 | ProcedureReturn #False 298 | EndIf 299 | 300 | If Position > *Object\Raw_Data_Size 301 | ProcedureReturn #False 302 | EndIf 303 | 304 | ; #### Reallocate if the operation increases the size of the object (Todo) 305 | Temp_Size = Position + Size - *Object\Raw_Data_Size 306 | If Temp_Size > 0 307 | *Object\Raw_Data_Size + Temp_Size 308 | New_Size = Quad_Divide_Ceil(*Object\Raw_Data_Size, #MemoryAllocation_Step) * #MemoryAllocation_Step 309 | If New_Size <> MemorySize(*Object\Raw_Data) And New_Size > 0 310 | *Temp = ReAllocateMemory(*Object\Raw_Data, New_Size) 311 | If *Temp 312 | *Object\Raw_Data = *Temp 313 | Else 314 | ProcedureReturn #False 315 | EndIf 316 | EndIf 317 | EndIf 318 | 319 | ;File_Size = Object_File_Get_Size(*Output) 320 | ;If Size + Position > File_Size 321 | ; Size = File_Size - Position 322 | ;EndIf 323 | 324 | Result = Memory::Range_Copy(*Data, 0, *Object\Raw_Data, Position, Size, Size, *Object\Raw_Data_Size) 325 | 326 | Event\Type = Node::#Link_Event_Update 327 | Event\Position = Position 328 | Event\Size = Size 329 | Node::Output_Event(FirstElement(*Node\Output()), Event) 330 | 331 | ProcedureReturn Result 332 | EndProcedure 333 | 334 | Procedure Shift(*Output.Node::Conn_Output, Position.q, Offset.q) 335 | Protected New_Size.i, *Temp 336 | Protected Raw_Data_Size_Old.q 337 | Protected Event.Node::Event 338 | 339 | If Not *Output 340 | ProcedureReturn #False 341 | EndIf 342 | Protected *Node.Node::Object = *Output\Object 343 | If Not *Node 344 | ProcedureReturn #False 345 | EndIf 346 | If Position < 0 347 | ProcedureReturn #False 348 | EndIf 349 | 350 | Protected *Object.Object = *Node\Custom_Data 351 | If Not *Object 352 | ProcedureReturn #False 353 | EndIf 354 | 355 | If Position > *Object\Raw_Data_Size 356 | ProcedureReturn #False 357 | EndIf 358 | 359 | If Offset < Position - *Object\Raw_Data_Size 360 | Offset = Position - *Object\Raw_Data_Size 361 | EndIf 362 | 363 | Raw_Data_Size_Old = *Object\Raw_Data_Size 364 | *Object\Raw_Data_Size + Offset 365 | 366 | If Offset < 0 367 | Memory::Range_Move(*Object\Raw_Data+Position, 0, *Object\Raw_Data+Position, Offset, Raw_Data_Size_Old-Position, Raw_Data_Size_Old-Position, Raw_Data_Size_Old-Position) 368 | EndIf 369 | 370 | New_Size = Quad_Divide_Ceil(*Object\Raw_Data_Size, #MemoryAllocation_Step) * #MemoryAllocation_Step 371 | If New_Size <> MemorySize(*Object\Raw_Data) And New_Size > 0 372 | *Temp = ReAllocateMemory(*Object\Raw_Data, New_Size) 373 | If *Temp 374 | *Object\Raw_Data = *Temp 375 | Else 376 | ProcedureReturn #False 377 | EndIf 378 | EndIf 379 | 380 | If Offset > 0 381 | Memory::Range_Move(*Object\Raw_Data, Position, *Object\Raw_Data, Position+Offset, Raw_Data_Size_Old-Position, Raw_Data_Size_Old, *Object\Raw_Data_Size) 382 | If Position + Offset <= *Object\Raw_Data_Size ; probably redundant 383 | FillMemory(*Object\Raw_Data+Position, Offset) 384 | EndIf 385 | EndIf 386 | 387 | Event\Type = Node::#Link_Event_Update 388 | Event\Position = Position 389 | Event\Size = Raw_Data_Size_Old - Position 390 | Node::Output_Event(FirstElement(*Node\Output()), Event) 391 | 392 | ProcedureReturn #True 393 | EndProcedure 394 | 395 | ; ################################################### Initialisation ############################################## 396 | 397 | Main\Node_Type = Node_Type::Create() 398 | If Main\Node_Type 399 | Main\Node_Type\Category = "Data-Source" 400 | Main\Node_Type\Name = "Dummy" 401 | Main\Node_Type\UID = "D3_DUMMY" 402 | Main\Node_Type\Author = "David Vogel (Dadido3)" 403 | Main\Node_Type\Date_Creation = Date(2014,01,12,14,02,00) 404 | Main\Node_Type\Date_Modification = Date(2014,01,12,14,02,00) 405 | Main\Node_Type\Date_Compilation = #PB_Compiler_Date 406 | Main\Node_Type\Description = "Virtual data object." 407 | Main\Node_Type\Function_Create = @Create() 408 | Main\Node_Type\Version = 1000 409 | EndIf 410 | 411 | ; ################################################### Main ######################################################## 412 | 413 | ; ################################################### End ######################################################### 414 | 415 | EndModule 416 | 417 | ; IDE Options = PureBasic 5.31 (Windows - x64) 418 | ; CursorPosition = 270 419 | ; FirstLine = 243 420 | ; Folding = -- 421 | ; EnableUnicode 422 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Nodes/Editor/Editor_Goto.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; Can handle up to $7FFFFFFFFFFFFFFF bytes of data 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ##################################################### Includes #################################################### 28 | 29 | ; ##################################################### Prototypes ################################################## 30 | 31 | ; ##################################################### Macros ###################################################### 32 | 33 | ; ##################################################### Constants ################################################### 34 | 35 | ; ##################################################### Structures ################################################## 36 | 37 | Structure Goto_Window 38 | *Window.Window::Object 39 | Window_Close.l 40 | 41 | ; #### Gadget stuff 42 | Frame.i 43 | Text.i[10] 44 | String.i[10] 45 | Button_Goto.i 46 | EndStructure 47 | 48 | ; ##################################################### Variables ################################################### 49 | 50 | ; ##################################################### Fonts ####################################################### 51 | 52 | ; ##################################################### Declares #################################################### 53 | 54 | Declare Goto_Window_Close(*Node.Node::Object) 55 | 56 | ; ##################################################### Procedures ################################################## 57 | 58 | Procedure Goto_Window_Event_Button_Goto() 59 | Protected Event_Window = EventWindow() 60 | Protected Event_Gadget = EventGadget() 61 | Protected Event_Type = EventType() 62 | 63 | Protected *Window.Window::Object = Window::Get(Event_Window) 64 | If Not *Window 65 | ProcedureReturn 66 | EndIf 67 | Protected *Node.Node::Object = *Window\Node 68 | If Not *Node 69 | ProcedureReturn 70 | EndIf 71 | Protected *Object.Object = *Node\Custom_Data 72 | If Not *Object 73 | ProcedureReturn 74 | EndIf 75 | Protected *Goto_Window.Goto_Window = *Object\Window_Goto 76 | If Not *Goto_Window 77 | ProcedureReturn 78 | EndIf 79 | 80 | Protected Select_Start.q = -1 81 | Protected Select_End.q = -1 82 | 83 | If GetGadgetText(*Goto_Window\String[0]) 84 | Select_Start = Val(GetGadgetText(*Goto_Window\String[0])) 85 | ElseIf GetGadgetText(*Goto_Window\String[1]) 86 | Select_Start = Val(GetGadgetText(*Goto_Window\String[1])) 87 | Else 88 | Select_Start = *Object\Select_Start 89 | EndIf 90 | 91 | If GetGadgetText(*Goto_Window\String[1]) 92 | Select_End = Val(GetGadgetText(*Goto_Window\String[1])) 93 | ElseIf GetGadgetText(*Goto_Window\String[0]) 94 | Select_End = Val(GetGadgetText(*Goto_Window\String[0])) 95 | Else 96 | Select_End = *Object\Select_End 97 | EndIf 98 | 99 | If Select_Start < 0 100 | Select_Start = 0 101 | EndIf 102 | If Select_End < 0 103 | Select_End = 0 104 | EndIf 105 | If Select_Start > *Object\Data_Size 106 | Select_Start = *Object\Data_Size 107 | EndIf 108 | If Select_End > *Object\Data_Size 109 | Select_End = *Object\Data_Size 110 | EndIf 111 | 112 | Range_Set(*Node, Select_Start, Select_End, #False, #True) 113 | 114 | EndProcedure 115 | 116 | Procedure Goto_Window_Event_CloseWindow() 117 | Protected Event_Window = EventWindow() 118 | Protected Event_Gadget = EventGadget() 119 | Protected Event_Type = EventType() 120 | 121 | Protected *Window.Window::Object = Window::Get(Event_Window) 122 | If Not *Window 123 | ProcedureReturn 124 | EndIf 125 | Protected *Node.Node::Object = *Window\Node 126 | If Not *Node 127 | ProcedureReturn 128 | EndIf 129 | Protected *Object.Object = *Node\Custom_Data 130 | If Not *Object 131 | ProcedureReturn 132 | EndIf 133 | Protected *Goto_Window.Goto_Window = *Object\Window_Goto 134 | If Not *Goto_Window 135 | ProcedureReturn 136 | EndIf 137 | 138 | ;Goto_Window_Close(*Node) 139 | *Goto_Window\Window_Close = #True 140 | EndProcedure 141 | 142 | Procedure Goto_Window_Open(*Node.Node::Object) 143 | Protected Width, Height 144 | 145 | If Not *Node 146 | ProcedureReturn #False 147 | EndIf 148 | Protected *Object.Object = *Node\Custom_Data 149 | If Not *Object 150 | ProcedureReturn #False 151 | EndIf 152 | Protected *Goto_Window.Goto_Window = *Object\Window_Goto 153 | If Not *Goto_Window 154 | ProcedureReturn #False 155 | EndIf 156 | 157 | If Not *Goto_Window\Window 158 | 159 | Width = 270 160 | Height = 130 161 | 162 | *Goto_Window\Window = Window::Create(*Node, "Editor_Goto", "Editor_Goto", 0, 0, Width, Height) 163 | 164 | ; #### Gadgets 165 | *Goto_Window\Frame = FrameGadget(#PB_Any, 10, 10, Width-20, 70, "Position") 166 | *Goto_Window\Text[0] = TextGadget(#PB_Any, 20, 30, 50, 20, "Start:", #PB_Text_Right) 167 | *Goto_Window\Text[1] = TextGadget(#PB_Any, 20, 50, 50, 20, "End:", #PB_Text_Right) 168 | *Goto_Window\String[0] = StringGadget(#PB_Any, 80, 30, Width-100, 20, Str(*Object\Select_Start)) 169 | *Goto_Window\String[1] = StringGadget(#PB_Any, 80, 50, Width-100, 20, Str(*Object\Select_End)) 170 | If *Object\Select_Start = *Object\Select_End 171 | SetGadgetText(*Goto_Window\String[1], "") 172 | EndIf 173 | *Goto_Window\Button_Goto = ButtonGadget(#PB_Any, Width-100, Height-40, 90, 30, "Goto") 174 | 175 | BindGadgetEvent(*Goto_Window\Button_Goto, @Goto_Window_Event_Button_Goto()) 176 | 177 | BindEvent(#PB_Event_CloseWindow, @Goto_Window_Event_CloseWindow(), *Goto_Window\Window\ID) 178 | 179 | Else 180 | Window::Set_Active(*Goto_Window\Window) 181 | EndIf 182 | EndProcedure 183 | 184 | Procedure Goto_Window_Close(*Node.Node::Object) 185 | If Not *Node 186 | ProcedureReturn #False 187 | EndIf 188 | Protected *Object.Object = *Node\Custom_Data 189 | If Not *Object 190 | ProcedureReturn #False 191 | EndIf 192 | Protected *Goto_Window.Goto_Window = *Object\Window_Goto 193 | If Not *Goto_Window 194 | ProcedureReturn #False 195 | EndIf 196 | 197 | If *Goto_Window\Window 198 | 199 | UnbindGadgetEvent(*Goto_Window\Button_Goto, @Goto_Window_Event_Button_Goto()) 200 | 201 | UnbindEvent(#PB_Event_CloseWindow, @Goto_Window_Event_CloseWindow(), *Goto_Window\Window\ID) 202 | 203 | Window::Delete(*Goto_Window\Window) 204 | *Goto_Window\Window = #Null 205 | EndIf 206 | EndProcedure 207 | 208 | Procedure Goto_Main(*Node.Node::Object) 209 | If Not *Node 210 | ProcedureReturn #False 211 | EndIf 212 | Protected *Object.Object = *Node\Custom_Data 213 | If Not *Object 214 | ProcedureReturn #False 215 | EndIf 216 | Protected *Goto_Window.Goto_Window = *Object\Window_Goto 217 | If Not *Goto_Window 218 | ProcedureReturn #False 219 | EndIf 220 | 221 | If *Goto_Window\Window 222 | 223 | EndIf 224 | 225 | If *Goto_Window\Window_Close 226 | *Goto_Window\Window_Close = #False 227 | Goto_Window_Close(*Node) 228 | EndIf 229 | 230 | EndProcedure 231 | 232 | ; ##################################################### Initialisation ############################################## 233 | 234 | ; ##################################################### Main ######################################################## 235 | 236 | ; ##################################################### End ######################################################### 237 | 238 | 239 | ; IDE Options = PureBasic 5.31 (Windows - x64) 240 | ; CursorPosition = 162 241 | ; FirstLine = 152 242 | ; Folding = - 243 | ; EnableUnicode 244 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Nodes/Random/Random.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ################################################################################################################### 28 | ; ##################################################### Public ###################################################### 29 | ; ################################################################################################################### 30 | 31 | DeclareModule _Node_Random 32 | EnableExplicit 33 | 34 | ; ################################################### Functions ################################################### 35 | Declare Create(Requester) 36 | 37 | EndDeclareModule 38 | 39 | ; ################################################################################################################### 40 | ; ##################################################### Private ##################################################### 41 | ; ################################################################################################################### 42 | 43 | Module _Node_Random 44 | ; ################################################### Includes #################################################### 45 | UseModule Constants 46 | UseModule Helper 47 | 48 | ; ################################################### Includes #################################################### 49 | 50 | ; ################################################### Prototypes ################################################## 51 | 52 | ; ################################################### Structures ################################################## 53 | 54 | ; ################################################### Constants ################################################### 55 | 56 | #Chunk_Size = 128 57 | 58 | ; ################################################### Structures ################################################## 59 | 60 | Structure Main 61 | *Node_Type.Node_Type::Object 62 | EndStructure 63 | Global Main.Main 64 | 65 | Structure Object 66 | *Window.Window::Object 67 | Window_Close.l 68 | 69 | ; #### Gadget stuff 70 | Text.i[10] 71 | String.i[10] 72 | 73 | ; #### Random stuff 74 | 75 | Size.q 76 | Seed.q 77 | 78 | EndStructure 79 | 80 | ; ################################################### Variables ################################################### 81 | 82 | ; ################################################### Declares #################################################### 83 | 84 | Declare Main(*Node.Node::Object) 85 | Declare _Delete(*Node.Node::Object) 86 | Declare Window_Open(*Node.Node::Object) 87 | 88 | Declare Configuration_Get(*Node.Node::Object, *Parent_Tag.NBT::Tag) 89 | Declare Configuration_Set(*Node.Node::Object, *Parent_Tag.NBT::Tag) 90 | 91 | Declare Get_Descriptor(*Output.Node::Conn_Output) 92 | Declare.q Get_Size(*Output.Node::Conn_Output) 93 | Declare Get_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data, *Metadata) 94 | Declare Set_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data) 95 | Declare Shift(*Output.Node::Conn_Output, Position.q, Offset.q) 96 | Declare Set_Data_Check(*Output.Node::Conn_Output, Position.q, Size.i) 97 | Declare Shift_Check(*Output.Node::Conn_Output, Position.q, Offset.q) 98 | 99 | Declare Window_Close(*Node.Node::Object) 100 | 101 | ; ################################################### Procedures ################################################## 102 | 103 | Procedure Create(Requester) 104 | Protected *Node.Node::Object = Node::_Create() 105 | Protected *Object.Object 106 | Protected *Output.Node::Conn_Output 107 | 108 | If Not *Node 109 | ProcedureReturn #False 110 | EndIf 111 | 112 | *Node\Type = Main\Node_Type 113 | *Node\Type_Base = Main\Node_Type 114 | 115 | *Node\Function_Delete = @_Delete() 116 | *Node\Function_Main = @Main() 117 | *Node\Function_Window = @Window_Open() 118 | *Node\Function_Configuration_Get = @Configuration_Get() 119 | *Node\Function_Configuration_Set = @Configuration_Set() 120 | 121 | *Node\Name = Main\Node_Type\Name 122 | *Node\Name_Inherited = *Node\Name 123 | *Node\Color = RGBA(Random(100)+50,Random(100)+50,Random(100)+50,255) 124 | 125 | *Node\Custom_Data = AllocateStructure(Object) 126 | *Object = *Node\Custom_Data 127 | 128 | *Object\Size = 1000000 129 | 130 | ; #### Add Output 131 | *Output = Node::Output_Add(*Node) 132 | *Output\Function_Get_Descriptor = @Get_Descriptor() 133 | *Output\Function_Get_Size = @Get_Size() 134 | *Output\Function_Get_Data = @Get_Data() 135 | *Output\Function_Set_Data = @Set_Data() 136 | *Output\Function_Shift = @Shift() 137 | *Output\Function_Set_Data_Check = @Set_Data_Check() 138 | *Output\Function_Shift_Check = @Shift_Check() 139 | 140 | If Requester 141 | Window_Open(*Node) 142 | EndIf 143 | 144 | ProcedureReturn *Node 145 | EndProcedure 146 | 147 | Procedure _Delete(*Node.Node::Object) 148 | If Not *Node 149 | ProcedureReturn #False 150 | EndIf 151 | 152 | Protected *Object.Object = *Node\Custom_Data 153 | If Not *Object 154 | ProcedureReturn #False 155 | EndIf 156 | 157 | Window_Close(*Node) 158 | 159 | FreeStructure(*Object) 160 | *Node\Custom_Data = #Null 161 | 162 | ProcedureReturn #True 163 | EndProcedure 164 | 165 | Procedure Configuration_Get(*Node.Node::Object, *Parent_Tag.NBT::Tag) 166 | Protected *NBT_Tag.NBT::Tag 167 | 168 | If Not *Node 169 | ProcedureReturn #False 170 | EndIf 171 | Protected *Object.Object = *Node\Custom_Data 172 | If Not *Object 173 | ProcedureReturn #False 174 | EndIf 175 | If Not *Parent_Tag 176 | ProcedureReturn #False 177 | EndIf 178 | 179 | *NBT_Tag = NBT::Tag_Add(*Parent_Tag, "Size", NBT::#Tag_Quad) : NBT::Tag_Set_Number(*NBT_Tag, *Object\Size) 180 | *NBT_Tag = NBT::Tag_Add(*Parent_Tag, "Seed", NBT::#Tag_Quad) : NBT::Tag_Set_Number(*NBT_Tag, *Object\Seed) 181 | 182 | ProcedureReturn #True 183 | EndProcedure 184 | 185 | Procedure Configuration_Set(*Node.Node::Object, *Parent_Tag.NBT::Tag) 186 | Protected *NBT_Tag.NBT::Tag 187 | Protected New_Size.i, *Temp 188 | 189 | If Not *Node 190 | ProcedureReturn #False 191 | EndIf 192 | Protected *Object.Object = *Node\Custom_Data 193 | If Not *Object 194 | ProcedureReturn #False 195 | EndIf 196 | If Not *Parent_Tag 197 | ProcedureReturn #False 198 | EndIf 199 | 200 | *NBT_Tag = NBT::Tag(*Parent_Tag, "Size") : *Object\Size = NBT::Tag_Get_Number(*NBT_Tag) 201 | *NBT_Tag = NBT::Tag(*Parent_Tag, "Seed") : *Object\Seed = NBT::Tag_Get_Number(*NBT_Tag) 202 | 203 | ProcedureReturn #True 204 | EndProcedure 205 | 206 | Procedure Get_Descriptor(*Output.Node::Conn_Output) 207 | If Not *Output 208 | ProcedureReturn #Null 209 | EndIf 210 | Protected *Node.Node::Object = *Output\Object 211 | If Not *Node 212 | ProcedureReturn #Null 213 | EndIf 214 | 215 | Protected *Object.Object = *Node\Custom_Data 216 | If Not *Object 217 | ProcedureReturn #Null 218 | EndIf 219 | 220 | NBT::Tag_Set_String(NBT::Tag_Add(*Output\Descriptor\Tag, "Name", NBT::#Tag_String), "Random data") 221 | 222 | ProcedureReturn *Output\Descriptor 223 | EndProcedure 224 | 225 | Procedure.q Get_Size(*Output.Node::Conn_Output) 226 | If Not *Output 227 | ProcedureReturn -1 228 | EndIf 229 | Protected *Node.Node::Object = *Output\Object 230 | If Not *Node 231 | ProcedureReturn -1 232 | EndIf 233 | 234 | Protected *Object.Object = *Node\Custom_Data 235 | If Not *Object 236 | ProcedureReturn -1 237 | EndIf 238 | 239 | ProcedureReturn *Object\Size 240 | EndProcedure 241 | 242 | Procedure Get_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data, *Metadata) 243 | If Not *Output 244 | ProcedureReturn #False 245 | EndIf 246 | Protected *Node.Node::Object = *Output\Object 247 | If Not *Node 248 | ProcedureReturn #False 249 | EndIf 250 | If Position < 0 251 | ProcedureReturn #False 252 | EndIf 253 | 254 | Protected *Object.Object = *Node\Custom_Data 255 | If Not *Object 256 | ProcedureReturn #False 257 | EndIf 258 | 259 | If Position > *Object\Size 260 | ProcedureReturn #False 261 | EndIf 262 | If Size > *Object\Size - Position 263 | Size = *Object\Size - Position 264 | EndIf 265 | If Size <= 0 266 | ProcedureReturn #False 267 | EndIf 268 | 269 | Protected *Temp, Temp_Size 270 | Protected N_Position.q ; Normalized position 271 | Protected i, Chunks.q, Start_Chunk.q 272 | 273 | Start_Chunk = Position / #Chunk_Size 274 | N_Position = Start_Chunk * #Chunk_Size 275 | Chunks = Quad_Divide_Ceil((Position - N_Position) + Size, #Chunk_Size) 276 | Temp_Size = Chunks * #Chunk_Size 277 | If Temp_Size 278 | *Temp = AllocateMemory(Temp_Size) 279 | If *Temp 280 | 281 | For i = 0 To Chunks-1 282 | RandomSeed(*Object\Seed) 283 | RandomSeed(Start_Chunk + i + Random(2147483647)) 284 | RandomData(*Temp+i*#Chunk_Size, #Chunk_Size) 285 | Next 286 | 287 | CopyMemory(*Temp + (Position - N_Position), *Data, Size) 288 | 289 | FreeMemory(*Temp) 290 | 291 | EndIf 292 | EndIf 293 | 294 | If *Metadata 295 | FillMemory(*Metadata, Size, #Metadata_NoError | #Metadata_Readable, #PB_Ascii) 296 | EndIf 297 | 298 | ProcedureReturn #True 299 | EndProcedure 300 | 301 | Procedure Set_Data(*Output.Node::Conn_Output, Position.q, Size.i, *Data) 302 | If Not *Output 303 | ProcedureReturn #False 304 | EndIf 305 | Protected *Node.Node::Object = *Output\Object 306 | If Not *Node 307 | ProcedureReturn #False 308 | EndIf 309 | 310 | ProcedureReturn #False 311 | EndProcedure 312 | 313 | Procedure Shift(*Output.Node::Conn_Output, Position.q, Offset.q) 314 | If Not *Output 315 | ProcedureReturn #False 316 | EndIf 317 | Protected *Node.Node::Object = *Output\Object 318 | If Not *Node 319 | ProcedureReturn #False 320 | EndIf 321 | 322 | ProcedureReturn #False 323 | EndProcedure 324 | 325 | Procedure Set_Data_Check(*Output.Node::Conn_Output, Position.q, Size.i) 326 | If Not *Output 327 | ProcedureReturn #False 328 | EndIf 329 | Protected *Node.Node::Object = *Output\Object 330 | If Not *Node 331 | ProcedureReturn #False 332 | EndIf 333 | 334 | ProcedureReturn #False 335 | EndProcedure 336 | 337 | Procedure Shift_Check(*Output.Node::Conn_Output, Position.q, Offset.q) 338 | If Not *Output 339 | ProcedureReturn #False 340 | EndIf 341 | Protected *Node.Node::Object = *Output\Object 342 | If Not *Node 343 | ProcedureReturn #False 344 | EndIf 345 | 346 | ProcedureReturn #False 347 | EndProcedure 348 | 349 | Procedure Window_Event_String_0() 350 | Protected Event_Window = EventWindow() 351 | Protected Event_Gadget = EventGadget() 352 | Protected Event_Type = EventType() 353 | 354 | Protected *Window.Window::Object = Window::Get(Event_Window) 355 | If Not *Window 356 | ProcedureReturn 357 | EndIf 358 | Protected *Node.Node::Object = *Window\Node 359 | If Not *Node 360 | ProcedureReturn 361 | EndIf 362 | Protected *Object.Object = *Node\Custom_Data 363 | If Not *Object 364 | ProcedureReturn 365 | EndIf 366 | 367 | Protected Event.Node::Event 368 | 369 | If Event_Type = #PB_EventType_Change 370 | *Object\Size = Val(GetGadgetText(Event_Gadget)) 371 | 372 | If *Object\Size < 0 373 | *Object\Size = 0 374 | EndIf 375 | 376 | Event\Type = Node::#Link_Event_Update 377 | Event\Position = 0 378 | Event\Size = *Object\Size 379 | Node::Output_Event(FirstElement(*Node\Output()), Event) 380 | 381 | EndIf 382 | 383 | EndProcedure 384 | 385 | Procedure Window_Event_String_1() 386 | Protected Event_Window = EventWindow() 387 | Protected Event_Gadget = EventGadget() 388 | Protected Event_Type = EventType() 389 | 390 | Protected *Window.Window::Object = Window::Get(Event_Window) 391 | If Not *Window 392 | ProcedureReturn 393 | EndIf 394 | Protected *Node.Node::Object = *Window\Node 395 | If Not *Node 396 | ProcedureReturn 397 | EndIf 398 | Protected *Object.Object = *Node\Custom_Data 399 | If Not *Object 400 | ProcedureReturn 401 | EndIf 402 | 403 | Protected Event.Node::Event 404 | 405 | If Event_Type = #PB_EventType_Change 406 | *Object\Seed = Val(GetGadgetText(Event_Gadget)) 407 | 408 | Event\Type = Node::#Link_Event_Update 409 | Event\Position = 0 410 | Event\Size = *Object\Size 411 | Node::Output_Event(FirstElement(*Node\Output()), Event) 412 | 413 | EndIf 414 | 415 | EndProcedure 416 | 417 | Procedure Window_Event_SizeWindow() 418 | Protected Event_Window = EventWindow() 419 | 420 | Protected *Window.Window::Object = Window::Get(Event_Window) 421 | If Not *Window 422 | ProcedureReturn 423 | EndIf 424 | Protected *Node.Node::Object = *Window\Node 425 | If Not *Node 426 | ProcedureReturn 427 | EndIf 428 | Protected *Object.Object = *Node\Custom_Data 429 | If Not *Object 430 | ProcedureReturn 431 | EndIf 432 | 433 | ;ResizeGadget(*Object\Canvas, #PB_Ignore, #PB_Ignore, WindowWidth(Event_Window)-17, WindowHeight(Event_Window)-ToolBarHeight) 434 | ;ResizeGadget(*Object\ScrollBar, WindowWidth(Event_Window)-17, #PB_Ignore, 17, WindowHeight(Event_Window)-ToolBarHeight) 435 | 436 | EndProcedure 437 | 438 | Procedure Window_Event_ActivateWindow() 439 | Protected Event_Window = EventWindow() 440 | Protected Event_Gadget = EventGadget() 441 | Protected Event_Type = EventType() 442 | 443 | Protected *Window.Window::Object = Window::Get(Event_Window) 444 | If Not *Window 445 | ProcedureReturn 446 | EndIf 447 | Protected *Node.Node::Object = *Window\Node 448 | If Not *Node 449 | ProcedureReturn 450 | EndIf 451 | Protected *Object.Object = *Node\Custom_Data 452 | If Not *Object 453 | ProcedureReturn 454 | EndIf 455 | 456 | EndProcedure 457 | 458 | Procedure Window_Event_Menu() 459 | Protected Event_Window = EventWindow() 460 | Protected Event_Gadget = EventGadget() 461 | Protected Event_Type = EventType() 462 | Protected Event_Menu = EventMenu() 463 | 464 | Select Event_Menu 465 | 466 | EndSelect 467 | EndProcedure 468 | 469 | Procedure Window_Event_CloseWindow() 470 | Protected Event_Window = EventWindow() 471 | Protected Event_Gadget = EventGadget() 472 | Protected Event_Type = EventType() 473 | 474 | Protected *Window.Window::Object = Window::Get(Event_Window) 475 | If Not *Window 476 | ProcedureReturn 477 | EndIf 478 | Protected *Node.Node::Object = *Window\Node 479 | If Not *Node 480 | ProcedureReturn 481 | EndIf 482 | Protected *Object.Object = *Node\Custom_Data 483 | If Not *Object 484 | ProcedureReturn 485 | EndIf 486 | 487 | ;Window_Close(*Node) 488 | *Object\Window_Close = #True 489 | EndProcedure 490 | 491 | Procedure Window_Open(*Node.Node::Object) 492 | Protected Width, Height 493 | 494 | If Not *Node 495 | ProcedureReturn #False 496 | EndIf 497 | Protected *Object.Object = *Node\Custom_Data 498 | If Not *Object 499 | ProcedureReturn #False 500 | EndIf 501 | 502 | If Not *Object\Window 503 | 504 | Width = 200 505 | Height = 60 506 | 507 | *Object\Window = Window::Create(*Node, *Node\Name_Inherited, *Node\Name, 0, 0, Width, Height) 508 | 509 | ; #### Toolbar 510 | 511 | ; #### Gadgets 512 | *Object\Text[0] = TextGadget(#PB_Any, 10, 10, 50, 20, "Size:", #PB_Text_Right) 513 | *Object\Text[1] = TextGadget(#PB_Any, 10, 30, 50, 20, "Seed:", #PB_Text_Right) 514 | *Object\String[0] = StringGadget(#PB_Any, 70, 10, Width-80, 20, Str(*Object\Size)) 515 | *Object\String[1] = StringGadget(#PB_Any, 70, 30, Width-80, 20, Str(*Object\Seed), #PB_String_Numeric) 516 | 517 | BindEvent(#PB_Event_SizeWindow, @Window_Event_SizeWindow(), *Object\Window\ID) 518 | BindEvent(#PB_Event_Menu, @Window_Event_Menu(), *Object\Window\ID) 519 | BindEvent(#PB_Event_CloseWindow, @Window_Event_CloseWindow(), *Object\Window\ID) 520 | BindGadgetEvent(*Object\String[0], @Window_Event_String_0()) 521 | BindGadgetEvent(*Object\String[1], @Window_Event_String_1()) 522 | 523 | Else 524 | Window::Set_Active(*Object\Window) 525 | EndIf 526 | EndProcedure 527 | 528 | Procedure Window_Close(*Node.Node::Object) 529 | If Not *Node 530 | ProcedureReturn #False 531 | EndIf 532 | Protected *Object.Object = *Node\Custom_Data 533 | If Not *Object 534 | ProcedureReturn #False 535 | EndIf 536 | 537 | If *Object\Window 538 | 539 | UnbindEvent(#PB_Event_SizeWindow, @Window_Event_SizeWindow(), *Object\Window\ID) 540 | UnbindEvent(#PB_Event_Menu, @Window_Event_Menu(), *Object\Window\ID) 541 | UnbindEvent(#PB_Event_CloseWindow, @Window_Event_CloseWindow(), *Object\Window\ID) 542 | UnbindGadgetEvent(*Object\String[0], @Window_Event_String_0()) 543 | UnbindGadgetEvent(*Object\String[1], @Window_Event_String_1()) 544 | 545 | Window::Delete(*Object\Window) 546 | *Object\Window = #Null 547 | EndIf 548 | EndProcedure 549 | 550 | Procedure Main(*Node.Node::Object) 551 | If Not *Node 552 | ProcedureReturn #False 553 | EndIf 554 | Protected *Object.Object = *Node\Custom_Data 555 | If Not *Object 556 | ProcedureReturn #False 557 | EndIf 558 | 559 | If *Object\Window 560 | 561 | EndIf 562 | 563 | If *Object\Window_Close 564 | *Object\Window_Close = #False 565 | Window_Close(*Node) 566 | EndIf 567 | 568 | ProcedureReturn #True 569 | EndProcedure 570 | 571 | ; ################################################### Initialisation ############################################## 572 | 573 | Main\Node_Type = Node_Type::Create() 574 | If Main\Node_Type 575 | Main\Node_Type\Category = "Data-Source" 576 | Main\Node_Type\Name = "Random" 577 | Main\Node_Type\UID = "D3__RAND" 578 | Main\Node_Type\Author = "David Vogel (Dadido3)" 579 | Main\Node_Type\Date_Creation = Date(2014,02,17,07,43,00) 580 | Main\Node_Type\Date_Modification = Date(2014,02,17,07,43,00) 581 | Main\Node_Type\Date_Compilation = #PB_Compiler_Date 582 | Main\Node_Type\Description = "Random data." 583 | Main\Node_Type\Function_Create = @Create() 584 | Main\Node_Type\Version = 1000 585 | EndIf 586 | 587 | ; ################################################### Main ######################################################## 588 | 589 | ; ################################################### End ######################################################### 590 | 591 | EndModule 592 | 593 | ; IDE Options = PureBasic 5.31 (Windows - x64) 594 | ; CursorPosition = 418 595 | ; FirstLine = 413 596 | ; Folding = ---- 597 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Nodes/View1D/View1D_Settings.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ##################################################### Includes #################################################### 28 | 29 | ; ##################################################### Prototypes ################################################## 30 | 31 | ; ##################################################### Macros ###################################################### 32 | 33 | ; ##################################################### Constants ################################################### 34 | 35 | ; ##################################################### Structures ################################################## 36 | 37 | Structure Settings_Window 38 | *Window.Window::Object 39 | Window_Close.l 40 | 41 | Update_ListIcon.i 42 | Update_Data.i 43 | 44 | ; #### Input 45 | Frame_In.i 46 | ListIcon_In.i 47 | CheckBox_In.i 48 | Canvas_In.i 49 | Text_In.i [5] 50 | ComboBox_In.i 51 | Spin_In.i 52 | Button_In_Add.i 53 | Button_In_Delete.i 54 | EndStructure 55 | 56 | ; ##################################################### Variables ################################################### 57 | 58 | ; ##################################################### Fonts ####################################################### 59 | 60 | ; ##################################################### Declares #################################################### 61 | 62 | Declare Settings_Window_Close(*Node.Node::Object) 63 | 64 | ; ##################################################### Procedures ################################################## 65 | 66 | Procedure Settings_Update_ListIcon(*Node.Node::Object) 67 | Protected *Input.Node::Conn_Input 68 | Protected *Input_Channel.Input_Channel 69 | Protected i 70 | Protected Temp_Image 71 | 72 | If Not *Node 73 | ProcedureReturn #False 74 | EndIf 75 | Protected *Object.Object = *Node\Custom_Data 76 | If Not *Object 77 | ProcedureReturn #False 78 | EndIf 79 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 80 | If Not *Settings_Window 81 | ProcedureReturn #False 82 | EndIf 83 | 84 | ; #### Fill the ListIcon 85 | If GetGadgetState(*Settings_Window\ListIcon_In) >= 0 86 | *Input = GetGadgetItemData(*Settings_Window\ListIcon_In, GetGadgetState(*Settings_Window\ListIcon_In)) 87 | EndIf 88 | ClearGadgetItems(*Settings_Window\ListIcon_In) 89 | ForEach *Node\Input() 90 | *Input_Channel = *Node\Input()\Custom_Data 91 | If Not *Input_Channel 92 | ProcedureReturn #False 93 | EndIf 94 | AddGadgetItem(*Settings_Window\ListIcon_In, ListIndex(*Node\Input()), Str(*Node\Input()\i)) 95 | SetGadgetItemText(*Settings_Window\ListIcon_In, ListIndex(*Node\Input()), Str(*Input_Channel\Manually), 1) 96 | SetGadgetItemText(*Settings_Window\ListIcon_In, ListIndex(*Node\Input()), Str(*Input_Channel\ElementType), 2) 97 | SetGadgetItemText(*Settings_Window\ListIcon_In, ListIndex(*Node\Input()), Str(*Input_Channel\Offset), 3) 98 | SetGadgetItemData(*Settings_Window\ListIcon_In, ListIndex(*Node\Input()), *Node\Input()) 99 | 100 | Temp_Image = CreateImage(#PB_Any, 16, 16, 24, *Input_Channel\Color) 101 | If Temp_Image 102 | SetGadgetItemImage(*Settings_Window\ListIcon_In, ListIndex(*Node\Input()), ImageID(Temp_Image)) 103 | FreeImage(Temp_Image) 104 | EndIf 105 | 106 | Next 107 | For i = 0 To CountGadgetItems(*Settings_Window\ListIcon_In) - 1 108 | If GetGadgetItemData(*Settings_Window\ListIcon_In, i) = *Input 109 | SetGadgetState(*Settings_Window\ListIcon_In, i) 110 | ProcedureReturn #True 111 | EndIf 112 | Next 113 | 114 | If GetGadgetState(*Settings_Window\ListIcon_In) < 0 115 | SetGadgetState(*Settings_Window\ListIcon_In, 0) 116 | EndIf 117 | *Settings_Window\Update_Data = #True 118 | 119 | ProcedureReturn #True 120 | EndProcedure 121 | 122 | Procedure Settings_Update_Data(*Node.Node::Object) 123 | Protected *Input.Node::Conn_Input 124 | Protected *Input_Channel.Input_Channel 125 | Protected i 126 | 127 | If Not *Node 128 | ProcedureReturn #False 129 | EndIf 130 | Protected *Object.Object = *Node\Custom_Data 131 | If Not *Object 132 | ProcedureReturn #False 133 | EndIf 134 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 135 | If Not *Settings_Window 136 | ProcedureReturn #False 137 | EndIf 138 | 139 | If GetGadgetState(*Settings_Window\ListIcon_In) >= 0 140 | *Input = GetGadgetItemData(*Settings_Window\ListIcon_In, GetGadgetState(*Settings_Window\ListIcon_In)) 141 | DisableGadget(*Settings_Window\CheckBox_In, #False) 142 | DisableGadget(*Settings_Window\ComboBox_In, #False) 143 | DisableGadget(*Settings_Window\Spin_In, #False) 144 | DisableGadget(*Settings_Window\Button_In_Delete, #False) 145 | Else 146 | DisableGadget(*Settings_Window\CheckBox_In, #True) : SetGadgetState(*Settings_Window\CheckBox_In, #False) 147 | DisableGadget(*Settings_Window\ComboBox_In, #True) : SetGadgetState(*Settings_Window\ComboBox_In, -1) 148 | DisableGadget(*Settings_Window\Spin_In, #True) : SetGadgetState(*Settings_Window\Spin_In, 0) 149 | DisableGadget(*Settings_Window\Button_In_Delete, #True) 150 | EndIf 151 | ForEach *Node\Input() 152 | If *Node\Input() = *Input 153 | 154 | *Input_Channel = *Input\Custom_Data 155 | If Not *Input_Channel 156 | ProcedureReturn #False 157 | EndIf 158 | 159 | SetGadgetData(*Settings_Window\Canvas_In, *Input_Channel\Color) 160 | If StartDrawing(CanvasOutput(*Settings_Window\Canvas_In)) 161 | Box(0, 0, GadgetWidth(*Settings_Window\Canvas_In), GadgetHeight(*Settings_Window\Canvas_In), GetGadgetData(*Settings_Window\Canvas_In)) 162 | StopDrawing() 163 | EndIf 164 | 165 | SetGadgetState(*Settings_Window\CheckBox_In, *Input_Channel\Manually) 166 | 167 | SetGadgetState(*Settings_Window\Spin_In, *Input_Channel\Offset) 168 | For i = 0 To CountGadgetItems(*Settings_Window\ComboBox_In) - 1 169 | If GetGadgetItemData(*Settings_Window\ComboBox_In, i) = *Input_Channel\ElementType 170 | SetGadgetState(*Settings_Window\ComboBox_In, i) 171 | Break 172 | EndIf 173 | Next 174 | If GetGadgetState(*Settings_Window\CheckBox_In) 175 | ;DisableGadget(*Settings_Window\Canvas_In, #False) 176 | DisableGadget(*Settings_Window\ComboBox_In, #False) 177 | DisableGadget(*Settings_Window\Spin_In, #False) 178 | Else 179 | ;DisableGadget(*Settings_Window\Canvas_In, #True) 180 | DisableGadget(*Settings_Window\ComboBox_In, #True) 181 | DisableGadget(*Settings_Window\Spin_In, #True) 182 | EndIf 183 | 184 | ProcedureReturn #True 185 | EndIf 186 | Next 187 | 188 | ProcedureReturn #False 189 | EndProcedure 190 | 191 | Procedure Settings_Window_Event_ListIcon_In() 192 | Protected Event_Window = EventWindow() 193 | Protected Event_Gadget = EventGadget() 194 | Protected Event_Type = EventType() 195 | 196 | Protected *Window.Window::Object = Window::Get(Event_Window) 197 | If Not *Window 198 | ProcedureReturn 199 | EndIf 200 | Protected *Node.Node::Object = *Window\Node 201 | If Not *Node 202 | ProcedureReturn 203 | EndIf 204 | Protected *Object.Object = *Node\Custom_Data 205 | If Not *Object 206 | ProcedureReturn 207 | EndIf 208 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 209 | If Not *Settings_Window 210 | ProcedureReturn 211 | EndIf 212 | 213 | Settings_Update_Data(*Node) 214 | 215 | EndProcedure 216 | 217 | Procedure Settings_Window_Event_Value_Change() 218 | Protected Event_Window = EventWindow() 219 | Protected Event_Gadget = EventGadget() 220 | Protected Event_Type = EventType() 221 | 222 | Protected *Node_Input.Node::Conn_Input 223 | Protected *Input_Channel.Input_Channel 224 | Protected Result 225 | 226 | Protected *Window.Window::Object = Window::Get(Event_Window) 227 | If Not *Window 228 | ProcedureReturn 229 | EndIf 230 | Protected *Node.Node::Object = *Window\Node 231 | If Not *Node 232 | ProcedureReturn 233 | EndIf 234 | Protected *Object.Object = *Node\Custom_Data 235 | If Not *Object 236 | ProcedureReturn 237 | EndIf 238 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 239 | If Not *Settings_Window 240 | ProcedureReturn 241 | EndIf 242 | 243 | If GetGadgetState(*Settings_Window\ListIcon_In) >= 0 244 | *Node_Input = GetGadgetItemData(*Settings_Window\ListIcon_In, GetGadgetState(*Settings_Window\ListIcon_In)) 245 | EndIf 246 | ForEach *Node\Input() 247 | If *Node\Input() = *Node_Input 248 | *Input_Channel = *Node_Input\Custom_Data 249 | If Not *Input_Channel 250 | ProcedureReturn 251 | EndIf 252 | 253 | Select Event_Gadget 254 | Case *Settings_Window\CheckBox_In 255 | *Input_Channel\Manually = GetGadgetState(*Settings_Window\CheckBox_In) 256 | 257 | If GetGadgetState(*Settings_Window\CheckBox_In) 258 | DisableGadget(*Settings_Window\Canvas_In, #False) 259 | DisableGadget(*Settings_Window\ComboBox_In, #False) 260 | DisableGadget(*Settings_Window\Spin_In, #False) 261 | Else 262 | DisableGadget(*Settings_Window\Canvas_In, #True) 263 | DisableGadget(*Settings_Window\ComboBox_In, #True) 264 | DisableGadget(*Settings_Window\Spin_In, #True) 265 | EndIf 266 | 267 | Case *Settings_Window\Canvas_In 268 | Select Event_Type 269 | Case #PB_EventType_LeftClick 270 | Result = ColorRequester(GetGadgetData(*Settings_Window\Canvas_In)) 271 | If Result >= 0 272 | *Input_Channel\Color = Result 273 | SetGadgetData(*Settings_Window\Canvas_In, Result) 274 | If StartDrawing(CanvasOutput(*Settings_Window\Canvas_In)) 275 | Box(0, 0, GadgetWidth(*Settings_Window\Canvas_In), GadgetHeight(*Settings_Window\Canvas_In), GetGadgetData(*Settings_Window\Canvas_In)) 276 | StopDrawing() 277 | EndIf 278 | EndIf 279 | 280 | EndSelect 281 | 282 | Case *Settings_Window\ComboBox_In 283 | If GetGadgetState(*Settings_Window\ComboBox_In) >= 0 284 | *Input_Channel\ElementType = GetGadgetItemData(*Settings_Window\ComboBox_In, GetGadgetState(*Settings_Window\ComboBox_In)) 285 | EndIf 286 | 287 | Case *Settings_Window\Spin_In 288 | *Input_Channel\Offset = GetGadgetState(*Settings_Window\Spin_In) 289 | 290 | EndSelect 291 | 292 | *Object\Redraw = #True 293 | 294 | *Settings_Window\Update_ListIcon = #True 295 | 296 | EndIf 297 | Next 298 | 299 | EndProcedure 300 | 301 | Procedure Settings_Window_Event_Button_In_Add() 302 | Protected Event_Window = EventWindow() 303 | Protected Event_Gadget = EventGadget() 304 | Protected Event_Type = EventType() 305 | 306 | Protected *Input.Node::Conn_Input 307 | Protected *Input_Channel.Input_Channel 308 | 309 | Protected *Window.Window::Object = Window::Get(Event_Window) 310 | If Not *Window 311 | ProcedureReturn 312 | EndIf 313 | Protected *Node.Node::Object = *Window\Node 314 | If Not *Node 315 | ProcedureReturn 316 | EndIf 317 | Protected *Object.Object = *Node\Custom_Data 318 | If Not *Object 319 | ProcedureReturn 320 | EndIf 321 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 322 | If Not *Settings_Window 323 | ProcedureReturn 324 | EndIf 325 | 326 | ; #### Add Input 327 | *Input = Node::Input_Add(*Node) 328 | *Input\Custom_Data = AllocateStructure(Input_Channel) 329 | *Input\Function_Event = @Input_Event() 330 | 331 | *Input_Channel = *Input\Custom_Data 332 | *Input_Channel\ElementType = #Integer_U_8 333 | 334 | *Settings_Window\Update_ListIcon = #True 335 | EndProcedure 336 | 337 | Procedure Settings_Window_Event_Button_In_Delete() 338 | Protected Event_Window = EventWindow() 339 | Protected Event_Gadget = EventGadget() 340 | Protected Event_Type = EventType() 341 | 342 | Protected *Input.Node::Conn_Input 343 | 344 | Protected *Window.Window::Object = Window::Get(Event_Window) 345 | If Not *Window 346 | ProcedureReturn 347 | EndIf 348 | Protected *Node.Node::Object = *Window\Node 349 | If Not *Node 350 | ProcedureReturn 351 | EndIf 352 | Protected *Object.Object = *Node\Custom_Data 353 | If Not *Object 354 | ProcedureReturn 355 | EndIf 356 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 357 | If Not *Settings_Window 358 | ProcedureReturn 359 | EndIf 360 | 361 | If GetGadgetState(*Settings_Window\ListIcon_In) >= 0 362 | *Input = GetGadgetItemData(*Settings_Window\ListIcon_In, GetGadgetState(*Settings_Window\ListIcon_In)) 363 | EndIf 364 | ForEach *Node\Input() 365 | If *Node\Input() = *Input 366 | If *Node\Input()\Custom_Data 367 | FreeStructure(*Node\Input()\Custom_Data) 368 | *Node\Input()\Custom_Data = #Null 369 | EndIf 370 | Node::Input_Delete(*Node, *Node\Input()) 371 | 372 | *Settings_Window\Update_ListIcon = #True 373 | Break 374 | EndIf 375 | Next 376 | EndProcedure 377 | 378 | Procedure Settings_Window_Event_CloseWindow() 379 | Protected Event_Window = EventWindow() 380 | Protected Event_Gadget = EventGadget() 381 | Protected Event_Type = EventType() 382 | 383 | Protected *Window.Window::Object = Window::Get(Event_Window) 384 | If Not *Window 385 | ProcedureReturn 386 | EndIf 387 | Protected *Node.Node::Object = *Window\Node 388 | If Not *Node 389 | ProcedureReturn 390 | EndIf 391 | Protected *Object.Object = *Node\Custom_Data 392 | If Not *Object 393 | ProcedureReturn 394 | EndIf 395 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 396 | If Not *Settings_Window 397 | ProcedureReturn 398 | EndIf 399 | 400 | ;Settings_Window_Close(*Node) 401 | *Settings_Window\Window_Close = #True 402 | EndProcedure 403 | 404 | Procedure Settings_Window_Open(*Node.Node::Object) 405 | Protected Width, Height, Data_Width, Data_Height, ToolBarHeight, Canvas_X_Height, Canvas_Y_Width, ScrollBar_X_Height, ScrollBar_Y_Width 406 | 407 | If Not *Node 408 | ProcedureReturn #False 409 | EndIf 410 | Protected *Object.Object = *Node\Custom_Data 411 | If Not *Object 412 | ProcedureReturn #False 413 | EndIf 414 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 415 | If Not *Settings_Window 416 | ProcedureReturn #False 417 | EndIf 418 | 419 | If Not *Settings_Window\Window 420 | 421 | Width = 270 422 | Height = 410 423 | 424 | *Settings_Window\Window = Window::Create(*Node, "View1D_Settings", "View1D_Settings", 0, 0, Width, Height) 425 | 426 | ; #### Gadgets 427 | 428 | *Settings_Window\Frame_In = FrameGadget(#PB_Any, 10, 10, 250, 390, "Inputs") 429 | *Settings_Window\ListIcon_In = ListIconGadget(#PB_Any, 20, 30, 230, 200, "Input", 40, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_FullRowSelect) 430 | AddGadgetColumn(*Settings_Window\ListIcon_In, 1, "Manually", 60) 431 | AddGadgetColumn(*Settings_Window\ListIcon_In, 2, "Type", 50) 432 | AddGadgetColumn(*Settings_Window\ListIcon_In, 3, "Offset", 50) 433 | 434 | *Settings_Window\CheckBox_In = CheckBoxGadget(#PB_Any, 20, 240, 230, 20, "Manually") 435 | 436 | *Settings_Window\Text_In[0] = TextGadget(#PB_Any, 20, 270, 50, 20, "Color:", #PB_Text_Right) 437 | *Settings_Window\Canvas_In = CanvasGadget(#PB_Any, 80, 270, 170, 20) 438 | 439 | *Settings_Window\Text_In[1] = TextGadget(#PB_Any, 20, 300, 50, 20, "Type:", #PB_Text_Right) 440 | *Settings_Window\ComboBox_In = ComboBoxGadget(#PB_Any, 80, 300, 170, 20) 441 | AddGadgetItem(*Settings_Window\ComboBox_In, 0, "uint8") : SetGadgetItemData(*Settings_Window\ComboBox_In, 0, #Integer_U_8) 442 | AddGadgetItem(*Settings_Window\ComboBox_In, 1, "int8") : SetGadgetItemData(*Settings_Window\ComboBox_In, 1, #Integer_S_8) 443 | AddGadgetItem(*Settings_Window\ComboBox_In, 2, "uint16") : SetGadgetItemData(*Settings_Window\ComboBox_In, 2, #Integer_U_16) 444 | AddGadgetItem(*Settings_Window\ComboBox_In, 3, "int16") : SetGadgetItemData(*Settings_Window\ComboBox_In, 3, #Integer_S_16) 445 | AddGadgetItem(*Settings_Window\ComboBox_In, 4, "uint32") : SetGadgetItemData(*Settings_Window\ComboBox_In, 4, #Integer_U_32) 446 | AddGadgetItem(*Settings_Window\ComboBox_In, 5, "int32") : SetGadgetItemData(*Settings_Window\ComboBox_In, 5, #Integer_S_32) 447 | AddGadgetItem(*Settings_Window\ComboBox_In, 6, "uint64") : SetGadgetItemData(*Settings_Window\ComboBox_In, 6, #Integer_U_64) 448 | AddGadgetItem(*Settings_Window\ComboBox_In, 7, "int64") : SetGadgetItemData(*Settings_Window\ComboBox_In, 7, #Integer_S_64) 449 | AddGadgetItem(*Settings_Window\ComboBox_In, 8, "float32"): SetGadgetItemData(*Settings_Window\ComboBox_In, 8, #Float_32) 450 | AddGadgetItem(*Settings_Window\ComboBox_In, 9, "float64"): SetGadgetItemData(*Settings_Window\ComboBox_In, 9, #Float_64) 451 | 452 | *Settings_Window\Text_In[2] = TextGadget(#PB_Any, 20, 330, 50, 20, "Offset:", #PB_Text_Right) 453 | *Settings_Window\Spin_In = SpinGadget(#PB_Any, 80, 330, 170, 20, -2147483648, 2147483647, #PB_Spin_Numeric) 454 | ;*Settings_Window\Button_In_Color = ButtonGadget(#PB_Any, ) 455 | *Settings_Window\Button_In_Add = ButtonGadget(#PB_Any, 100, 360, 70, 30, "Add") 456 | *Settings_Window\Button_In_Delete = ButtonGadget(#PB_Any, 180, 360, 70, 30, "Delete") 457 | 458 | BindGadgetEvent(*Settings_Window\ListIcon_In, @Settings_Window_Event_ListIcon_In()) 459 | BindGadgetEvent(*Settings_Window\CheckBox_in, @Settings_Window_Event_Value_Change()) 460 | BindGadgetEvent(*Settings_Window\Canvas_In, @Settings_Window_Event_Value_Change()) 461 | BindGadgetEvent(*Settings_Window\ComboBox_In, @Settings_Window_Event_Value_Change()) 462 | BindGadgetEvent(*Settings_Window\Spin_In, @Settings_Window_Event_Value_Change()) 463 | BindGadgetEvent(*Settings_Window\Button_In_Add, @Settings_Window_Event_Button_In_Add()) 464 | BindGadgetEvent(*Settings_Window\Button_In_Delete, @Settings_Window_Event_Button_In_Delete()) 465 | 466 | BindEvent(#PB_Event_CloseWindow, @Settings_Window_Event_CloseWindow(), *Settings_Window\Window\ID) 467 | 468 | *Settings_Window\Update_ListIcon = #True 469 | Else 470 | Window::Set_Active(*Settings_Window\Window) 471 | EndIf 472 | EndProcedure 473 | 474 | Procedure Settings_Window_Close(*Node.Node::Object) 475 | If Not *Node 476 | ProcedureReturn #False 477 | EndIf 478 | Protected *Object.Object = *Node\Custom_Data 479 | If Not *Object 480 | ProcedureReturn #False 481 | EndIf 482 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 483 | If Not *Settings_Window 484 | ProcedureReturn #False 485 | EndIf 486 | 487 | If *Settings_Window\Window 488 | 489 | UnbindGadgetEvent(*Settings_Window\ListIcon_In, @Settings_Window_Event_ListIcon_In()) 490 | UnbindGadgetEvent(*Settings_Window\CheckBox_in, @Settings_Window_Event_Value_Change()) 491 | UnbindGadgetEvent(*Settings_Window\Canvas_In, @Settings_Window_Event_Value_Change()) 492 | UnbindGadgetEvent(*Settings_Window\ComboBox_In, @Settings_Window_Event_Value_Change()) 493 | UnbindGadgetEvent(*Settings_Window\Spin_In, @Settings_Window_Event_Value_Change()) 494 | UnbindGadgetEvent(*Settings_Window\Button_In_Add, @Settings_Window_Event_Button_In_Add()) 495 | UnbindGadgetEvent(*Settings_Window\Button_In_Delete, @Settings_Window_Event_Button_In_Delete()) 496 | 497 | UnbindEvent(#PB_Event_CloseWindow, @Settings_Window_Event_CloseWindow(), *Settings_Window\Window\ID) 498 | 499 | Window::Delete(*Settings_Window\Window) 500 | *Settings_Window\Window = #Null 501 | EndIf 502 | EndProcedure 503 | 504 | Procedure Settings_Main(*Node.Node::Object) 505 | If Not *Node 506 | ProcedureReturn #False 507 | EndIf 508 | Protected *Object.Object = *Node\Custom_Data 509 | If Not *Object 510 | ProcedureReturn #False 511 | EndIf 512 | Protected *Settings_Window.Settings_Window = *Object\Settings_Window 513 | If Not *Settings_Window 514 | ProcedureReturn #False 515 | EndIf 516 | 517 | If *Settings_Window\Window 518 | If *Settings_Window\Update_ListIcon 519 | *Settings_Window\Update_ListIcon = #False 520 | Settings_Update_ListIcon(*Node.Node::Object) 521 | EndIf 522 | If *Settings_Window\Update_Data 523 | *Settings_Window\Update_Data = #False 524 | Settings_Update_Data(*Node.Node::Object) 525 | EndIf 526 | EndIf 527 | 528 | If *Settings_Window\Window_Close 529 | *Settings_Window\Window_Close = #False 530 | Settings_Window_Close(*Node) 531 | EndIf 532 | EndProcedure 533 | 534 | ; ##################################################### Initialisation ############################################## 535 | 536 | ; ##################################################### Main ######################################################## 537 | 538 | ; ##################################################### End ######################################################### 539 | 540 | 541 | ; IDE Options = PureBasic 5.42 LTS (Windows - x64) 542 | ; CursorPosition = 450 543 | ; FirstLine = 416 544 | ; Folding = -- 545 | ; EnableXP -------------------------------------------------------------------------------- /Includes/UnitEngine.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; 28 | ; ################################################################################################################### 29 | ; ##################################################### Public ###################################################### 30 | ; ################################################################################################################### 31 | 32 | DeclareModule UnitEngine 33 | EnableExplicit 34 | ; ################################################### Constants ################################################### 35 | Enumeration 36 | #SiPrefix 37 | #BinaryPrefix 38 | EndEnumeration 39 | 40 | Enumeration 41 | #SiPrefix_Yocto 42 | #SiPrefix_Zepto 43 | #SiPrefix_Atto 44 | #SiPrefix_Femto 45 | #SiPrefix_Pico 46 | #SiPrefix_Nano 47 | #SiPrefix_Micro 48 | #SiPrefix_Milli 49 | #SiPrefix_Centi 50 | #SiPrefix_Deci 51 | 52 | #SiPrefix_None 53 | 54 | #SiPrefix_Deca 55 | #SiPrefix_Hecto 56 | #SiPrefix_Kilo 57 | #SiPrefix_Mega 58 | #SiPrefix_Giga 59 | #SiPrefix_Tera 60 | #SiPrefix_Peta 61 | #SiPrefix_Exa 62 | #SiPrefix_Zetta 63 | #SiPrefix_Yotta 64 | 65 | #SiPrefix_Amount 66 | EndEnumeration 67 | 68 | Enumeration 69 | #BinaryPrefix_None 70 | 71 | #BinaryPrefix_Kibi 72 | #BinaryPrefix_Mebi 73 | #BinaryPrefix_Gibi 74 | #BinaryPrefix_Tebi 75 | #BinaryPrefix_Pebi 76 | #BinaryPrefix_Exbi 77 | #BinaryPrefix_Zebi 78 | #BinaryPrefix_Yobi 79 | 80 | #BinaryPrefix_Amount 81 | EndEnumeration 82 | 83 | ; ################################################### Functions ################################################### 84 | Declare.s Format_Integer(Value.q, Prefix.i, Unit.s, NbDecimals.i=10) 85 | 86 | EndDeclareModule 87 | 88 | ; ################################################################################################################### 89 | ; ##################################################### Private ##################################################### 90 | ; ################################################################################################################### 91 | 92 | Module UnitEngine 93 | 94 | ; ################################################### Structures ################################################## 95 | Structure Main 96 | 97 | EndStructure 98 | Global Main.Main 99 | 100 | Structure SiPrefix 101 | Exponent.i ; (Factor = 10^Exponent) 102 | 103 | Symbol.s{2} 104 | EndStructure 105 | Global Dim SiPrefix.SiPrefix(#SiPrefix_Amount-1) 106 | 107 | Structure BinaryPrefix 108 | Exponent.i ; (Factor = 1024^Exponent) 109 | 110 | Symbol.s{2} 111 | EndStructure 112 | Global Dim BinaryPrefix.BinaryPrefix(#BinaryPrefix_Amount-1) 113 | 114 | ; ##################################################### Init ######################################################## 115 | ; #### SI Prefixes 116 | SiPrefix(#SiPrefix_Yocto)\Exponent = -24 117 | SiPrefix(#SiPrefix_Yocto)\Symbol = "y" 118 | SiPrefix(#SiPrefix_Zepto)\Exponent = -21 119 | SiPrefix(#SiPrefix_Zepto)\Symbol = "z" 120 | SiPrefix(#SiPrefix_Atto)\Exponent = -18 121 | SiPrefix(#SiPrefix_Atto)\Symbol = "a" 122 | SiPrefix(#SiPrefix_Femto)\Exponent = -15 123 | SiPrefix(#SiPrefix_Femto)\Symbol = "f" 124 | SiPrefix(#SiPrefix_Pico)\Exponent = -12 125 | SiPrefix(#SiPrefix_Pico)\Symbol = "p" 126 | SiPrefix(#SiPrefix_Nano)\Exponent = -9 127 | SiPrefix(#SiPrefix_Nano)\Symbol = "n" 128 | SiPrefix(#SiPrefix_Micro)\Exponent = -6 129 | SiPrefix(#SiPrefix_Micro)\Symbol = "µ" 130 | SiPrefix(#SiPrefix_Milli)\Exponent = -3 131 | SiPrefix(#SiPrefix_Milli)\Symbol = "m" 132 | SiPrefix(#SiPrefix_Centi)\Exponent = -2 133 | SiPrefix(#SiPrefix_Centi)\Symbol = "c" 134 | SiPrefix(#SiPrefix_Deci)\Exponent = -1 135 | SiPrefix(#SiPrefix_Deci)\Symbol = "d" 136 | 137 | SiPrefix(#SiPrefix_None)\Exponent = 0 138 | SiPrefix(#SiPrefix_None)\Symbol = "" 139 | 140 | SiPrefix(#SiPrefix_Deca)\Exponent = 1 141 | SiPrefix(#SiPrefix_Deca)\Symbol = "da" 142 | SiPrefix(#SiPrefix_Hecto)\Exponent = 2 143 | SiPrefix(#SiPrefix_Hecto)\Symbol = "h" 144 | SiPrefix(#SiPrefix_Kilo)\Exponent = 3 145 | SiPrefix(#SiPrefix_Kilo)\Symbol = "k" 146 | SiPrefix(#SiPrefix_Mega)\Exponent = 6 147 | SiPrefix(#SiPrefix_Mega)\Symbol = "M" 148 | SiPrefix(#SiPrefix_Giga)\Exponent = 9 149 | SiPrefix(#SiPrefix_Giga)\Symbol = "G" 150 | SiPrefix(#SiPrefix_Tera)\Exponent = 12 151 | SiPrefix(#SiPrefix_Tera)\Symbol = "T" 152 | SiPrefix(#SiPrefix_Peta)\Exponent = 15 153 | SiPrefix(#SiPrefix_Peta)\Symbol = "P" 154 | SiPrefix(#SiPrefix_Exa)\Exponent = 18 155 | SiPrefix(#SiPrefix_Exa)\Symbol = "E" 156 | SiPrefix(#SiPrefix_Zetta)\Exponent = 21 157 | SiPrefix(#SiPrefix_Zetta)\Symbol = "Z" 158 | SiPrefix(#SiPrefix_Yotta)\Exponent = 24 159 | SiPrefix(#SiPrefix_Yotta)\Symbol = "Y" 160 | 161 | ; #### Binary Prefixes 162 | SiPrefix(#BinaryPrefix_None)\Exponent = 0 163 | SiPrefix(#BinaryPrefix_None)\Symbol = "" 164 | 165 | SiPrefix(#BinaryPrefix_Kibi)\Exponent = 1 166 | SiPrefix(#BinaryPrefix_Kibi)\Symbol = "Ki" 167 | SiPrefix(#BinaryPrefix_Mebi)\Exponent = 2 168 | SiPrefix(#BinaryPrefix_Mebi)\Symbol = "Mi" 169 | SiPrefix(#BinaryPrefix_Gibi)\Exponent = 3 170 | SiPrefix(#BinaryPrefix_Gibi)\Symbol = "Gi" 171 | SiPrefix(#BinaryPrefix_Tebi)\Exponent = 4 172 | SiPrefix(#BinaryPrefix_Tebi)\Symbol = "Ti" 173 | SiPrefix(#BinaryPrefix_Pebi)\Exponent = 5 174 | SiPrefix(#BinaryPrefix_Pebi)\Symbol = "Pi" 175 | SiPrefix(#BinaryPrefix_Exbi)\Exponent = 6 176 | SiPrefix(#BinaryPrefix_Exbi)\Symbol = "Ei" 177 | SiPrefix(#BinaryPrefix_Zebi)\Exponent = 7 178 | SiPrefix(#BinaryPrefix_Zebi)\Symbol = "Zi" 179 | SiPrefix(#BinaryPrefix_Yobi)\Exponent = 8 180 | SiPrefix(#BinaryPrefix_Yobi)\Symbol = "Yi" 181 | 182 | ; ##################################################### Procedures ################################################## 183 | Procedure.s Format_Integer(Value.q, Prefix.i, Unit.s, NbDecimals.i=10) 184 | Protected Value_String.s 185 | Protected Factor.d 186 | Protected i 187 | 188 | Select Prefix 189 | Case #SiPrefix 190 | For i = #SiPrefix_Amount-1 To 0 Step -1 191 | Factor = Pow(10, SiPrefix(i)\Exponent) 192 | If Value / Factor >= 1 193 | ProcedureReturn RTrim(RTrim(StrD(Value / Factor, NbDecimals),"0"),".") + " " + SiPrefix(i)\Symbol + Unit 194 | EndIf 195 | Next 196 | i = 0 197 | Factor = Pow(10, SiPrefix(i)\Exponent) 198 | ProcedureReturn RTrim(RTrim(StrD(Value / Factor, NbDecimals),"0"),".") + " " + SiPrefix(i)\Symbol + Unit 199 | 200 | Case #BinaryPrefix 201 | For i = #BinaryPrefix_Amount-1 To 0 Step -1 202 | Factor = Pow(1024, BinaryPrefix(i)\Exponent) 203 | If Value / Factor >= 1 204 | ProcedureReturn RTrim(RTrim(StrD(Value / Factor, NbDecimals),"0"),".") + " " + BinaryPrefix(i)\Symbol + Unit 205 | EndIf 206 | Next 207 | i = 0 208 | Factor = Pow(1024, BinaryPrefix(i)\Exponent) 209 | ProcedureReturn RTrim(RTrim(StrD(Value / Factor, NbDecimals),"0"),".") + " " + BinaryPrefix(i)\Symbol + Unit 210 | 211 | EndSelect 212 | EndProcedure 213 | 214 | EndModule 215 | 216 | ; IDE Options = PureBasic 5.31 (Windows - x64) 217 | ; CursorPosition = 84 218 | ; FirstLine = 49 219 | ; Folding = - 220 | ; EnableUnicode 221 | ; EnableXP -------------------------------------------------------------------------------- /Includes/Window.pbi: -------------------------------------------------------------------------------- 1 | ; ##################################################### License / Copyright ######################################### 2 | ; 3 | ; D3hex 4 | ; Copyright (C) 2014-2017 David Vogel 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | ; 19 | ; ##################################################### Dokumentation / Kommentare ################################## 20 | ; 21 | ; 22 | ; 23 | ; 24 | ; 25 | ; 26 | ; 27 | ; ##################################################### Includes #################################################### 28 | 29 | ; ################################################################################################################### 30 | ; ##################################################### Public ###################################################### 31 | ; ################################################################################################################### 32 | 33 | DeclareModule Window 34 | EnableExplicit 35 | ; ################################################### Constants ################################################### 36 | Enumeration 37 | #Flag_Resizeable = %001 38 | #Flag_MaximizeGadget = %010 39 | #Flag_Docked = %100 40 | EndEnumeration 41 | 42 | ; ################################################### Structures ################################################## 43 | Structure KeyboardShortcut 44 | Key.i ; Key combination 45 | 46 | Event_Menu.i ; Menu event which will get posted to the child window 47 | Main_Menu.i ; Menu of the main window (like undo, copy, ...) 48 | EndStructure 49 | 50 | Structure Object 51 | ID.i 52 | Name.s 53 | Name_Short.s 54 | 55 | Tab_ID.s ; Windows with the same Tab_ID will be grouped into tabs if possible 56 | 57 | List KeyboardShortcut.KeyboardShortcut() 58 | 59 | *Node 60 | EndStructure 61 | Global NewList Object.Object() 62 | 63 | ; ################################################### Functions ################################################### 64 | Declare Get(ID.i) 65 | Declare Get_hWnd(hWnd.i) 66 | Declare Get_Active() 67 | Declare Set_Active(*Window.Object) 68 | Declare Bounds(*Window.Object, Min_Width.l, Min_Height.l, Max_Width.l, Max_Height.l) 69 | Declare Remove_KeyboardShortcut(*Window.Object, Key.i) 70 | Declare Set_KeyboardShortcut(*Window.Object, Key.i, Event_Menu.i, Main_Menu.i=0) 71 | 72 | Declare Create(*Object, Name.s, Name_Short.s, X=#PB_Ignore, Y=#PB_Ignore, Width=#PB_Ignore, Height=#PB_Ignore, Flags=0, Resize_Priority.l=0, Tab_ID.s="") 73 | Declare Delete(*Window.Object) 74 | 75 | Declare Init(Parent_Window, Docker, StatusBar) 76 | 77 | EndDeclareModule 78 | 79 | ; ################################################################################################################### 80 | ; ##################################################### Private ##################################################### 81 | ; ################################################################################################################### 82 | 83 | Module Window 84 | ; ################################################### Structures ################################################## 85 | Structure Main 86 | Parent_Window.i 87 | 88 | Docker.i 89 | StatusBar.i 90 | EndStructure 91 | Global Main.Main 92 | 93 | ; ################################################### Procedures ################################################## 94 | Procedure Get(ID.i) 95 | Protected *Result.Object = #Null 96 | 97 | PushListPosition(Object()) 98 | 99 | ForEach Object() 100 | If Object()\ID = ID 101 | *Result = Object() 102 | Break 103 | EndIf 104 | Next 105 | 106 | PopListPosition(Object()) 107 | 108 | ProcedureReturn *Result 109 | EndProcedure 110 | 111 | Procedure Get_hWnd(hWnd.i) 112 | Protected *Result.Object = #Null 113 | 114 | PushListPosition(Object()) 115 | 116 | ForEach Object() 117 | If Object()\ID And WindowID(Object()\ID) = hWnd 118 | *Result = Object() 119 | Break 120 | EndIf 121 | Next 122 | 123 | PopListPosition(Object()) 124 | 125 | ProcedureReturn *Result 126 | EndProcedure 127 | 128 | Procedure Get_Active() 129 | Protected *Result.Object = #Null 130 | Protected Active_ID = D3docker::Window_Get_Active(Main\Docker) 131 | 132 | PushListPosition(Object()) 133 | 134 | ForEach Object() 135 | If Object()\ID = Active_ID 136 | *Result = Object() 137 | Break 138 | EndIf 139 | Next 140 | 141 | PopListPosition(Object()) 142 | 143 | ProcedureReturn *Result 144 | EndProcedure 145 | 146 | Procedure Set_Active(*Window.Object) 147 | If Not *Window 148 | ProcedureReturn #False 149 | EndIf 150 | 151 | D3docker::Window_Set_Active(*Window\ID) 152 | 153 | StatusBarText(Main\StatusBar, 0, "") 154 | StatusBarText(Main\StatusBar, 1, "") 155 | StatusBarText(Main\StatusBar, 2, "") 156 | 157 | ;PostEvent(#PB_Event_SizeWindow, *Window\ID, 0) 158 | 159 | ProcedureReturn #True 160 | EndProcedure 161 | 162 | Procedure Bounds(*Window.Object, Min_Width.l, Min_Height.l, Max_Width.l, Max_Height.l) 163 | If Not *Window 164 | ProcedureReturn #False 165 | EndIf 166 | 167 | D3docker::Window_Bounds(*Window\ID, Min_Width, Min_Height, Max_Width, Max_Height) 168 | 169 | ProcedureReturn #True 170 | EndProcedure 171 | 172 | Procedure Remove_KeyboardShortcut(*Window.Object, Key.i) 173 | If Not *Window 174 | ProcedureReturn #False 175 | EndIf 176 | 177 | ForEach *Window\KeyboardShortcut() 178 | If *Window\KeyboardShortcut()\Key = Key 179 | DeleteElement(*Window\KeyboardShortcut()) 180 | EndIf 181 | Next 182 | 183 | If Key 184 | RemoveKeyboardShortcut(*Window\ID, Key) 185 | EndIf 186 | 187 | Main::Window_KeyboardShortcut_Update() ; #### Indirectly executed throught Set_KeyboardShortcut 188 | 189 | ProcedureReturn #True 190 | EndProcedure 191 | 192 | Procedure Set_KeyboardShortcut(*Window.Object, Key.i, Event_Menu.i, Main_Menu.i=0) 193 | If Not *Window 194 | ProcedureReturn #False 195 | EndIf 196 | 197 | Remove_KeyboardShortcut(*Window, Key) 198 | 199 | AddElement(*Window\KeyboardShortcut()) 200 | *Window\KeyboardShortcut()\Key = Key 201 | *Window\KeyboardShortcut()\Event_Menu = Event_Menu 202 | *Window\KeyboardShortcut()\Main_Menu = Main_Menu 203 | 204 | If Key 205 | AddKeyboardShortcut(*Window\ID, Key, Event_Menu) 206 | EndIf 207 | 208 | ProcedureReturn #True 209 | EndProcedure 210 | 211 | Procedure Event_ActivateWindow() 212 | Protected ID = EventWindow() 213 | 214 | Protected *Window.Object = Get(ID) 215 | If Not *Window 216 | ProcedureReturn 217 | EndIf 218 | 219 | Main::Window_KeyboardShortcut_Update() 220 | 221 | StatusBarText(Main\StatusBar, 0, "") 222 | StatusBarText(Main\StatusBar, 1, "") 223 | StatusBarText(Main\StatusBar, 2, "") 224 | 225 | EndProcedure 226 | 227 | Procedure Event_MaximizeWindow() 228 | Protected ID = EventWindow() 229 | Protected i 230 | 231 | Protected *Window.Object = Get(ID) 232 | If Not *Window 233 | ProcedureReturn 234 | EndIf 235 | ; TODO: Still needed? 236 | ;ForEach Object() 237 | ; PostEvent(#PB_Event_SizeWindow, Object()\ID, 0) 238 | ;Next 239 | 240 | EndProcedure 241 | 242 | Procedure Event_MinimizeWindow() 243 | Protected ID = EventWindow() 244 | Protected i 245 | 246 | Protected *Window.Object = Get(ID) 247 | If Not *Window 248 | ProcedureReturn 249 | EndIf 250 | ; TODO: Still needed? 251 | ;ForEach Object() 252 | ; PostEvent(#PB_Event_SizeWindow, Object()\ID, 0) 253 | ;Next 254 | 255 | EndProcedure 256 | 257 | Procedure Event_RestoreWindow() 258 | Protected ID = EventWindow() 259 | Protected i 260 | 261 | Protected *Window.Object = Get(ID) 262 | If Not *Window 263 | ProcedureReturn 264 | EndIf 265 | ; TODO: Still needed? 266 | ;ForEach Object() 267 | ;PostEvent(#PB_Event_SizeWindow, Object()\ID, 0) 268 | ;Next 269 | 270 | EndProcedure 271 | 272 | Procedure Create(*Object, Name.s, Name_Short.s, X=#PB_Ignore, Y=#PB_Ignore, Width=#PB_Ignore, Height=#PB_Ignore, Flags=0, Resize_Priority.l=0, Tab_ID.s="") 273 | Protected *Window.Object 274 | 275 | If Not AddElement(Object()) 276 | ProcedureReturn #Null 277 | EndIf 278 | 279 | *Window = Object() 280 | 281 | Protected Window_Flags 282 | Protected *Container 283 | Protected *Temp.Object 284 | 285 | If Flags & #Flag_Resizeable 286 | Window_Flags = #PB_Window_WindowCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget 287 | Else 288 | Window_Flags = #PB_Window_WindowCentered | #PB_Window_SystemMenu 289 | EndIf 290 | 291 | If Flags & #Flag_MaximizeGadget 292 | Window_Flags | #PB_Window_MaximizeGadget 293 | Else 294 | Window_Flags | #PB_Window_Tool 295 | EndIf 296 | 297 | ;*Window\MDI_Window = MDI 298 | *Window\Name = Name 299 | *Window\Name_Short = Name_Short 300 | ;If *Window\MDI_Window 301 | *Window\ID = D3docker::Window_Add(Main\Docker, X, Y, Width, Height, Name, Window_Flags, Resize_Priority) 302 | ;EndIf 303 | *Window\Node = *Object 304 | *Window\Tab_ID = Tab_ID 305 | 306 | ;SmartWindowRefresh(*Window\ID, 1) 307 | 308 | BindEvent(#PB_Event_ActivateWindow, @Event_ActivateWindow(), *Window\ID) 309 | ;BindEvent(#PB_Event_MaximizeWindow, @Event_MaximizeWindow(), *Window\ID) 310 | ;BindEvent(#PB_Event_MinimizeWindow, @Event_MinimizeWindow(), *Window\ID) 311 | ;BindEvent(#PB_Event_RestoreWindow, @Event_RestoreWindow(), *Window\ID) 312 | 313 | If Flags & #Flag_Docked 314 | ;*Temp = Get_Active() 315 | ;If *Temp 316 | ; *Container = D3docker::Get_Container(*Temp\ID) 317 | ;EndIf 318 | 319 | If Tab_ID 320 | ForEach Object() 321 | If Object()\Tab_ID = Tab_ID 322 | *Container = D3docker::Window_Get_Container(Object()\ID) 323 | If *Container 324 | Break 325 | EndIf 326 | EndIf 327 | Next 328 | EndIf 329 | 330 | If *Container 331 | D3docker::Docker_Add(Main\Docker, *Container, D3docker::#Direction_Inside, *Window\ID) 332 | Else 333 | *Container = D3docker::Root_Get(Main\Docker) 334 | If WindowWidth(*Window\ID) > WindowHeight(*Window\ID) 335 | D3docker::Docker_Add(Main\Docker, *Container, D3docker::#Direction_Bottom, *Window\ID) 336 | Else 337 | D3docker::Docker_Add(Main\Docker, *Container, D3docker::#Direction_Right, *Window\ID) 338 | EndIf 339 | EndIf 340 | 341 | EndIf 342 | 343 | ;If *Window\MDI_Window 344 | ; AddTabBarGadgetItem(Main_Window\Panel, #PB_Default, Name_Short, #Null, *Window\ID) 345 | ; SetWindowState(*Window\ID, #PB_Maximize) 346 | ; Main_Refresh_Active() 347 | ;Else 348 | ; #### Test 349 | ; SetParent_(WindowID(*Window\ID ), WindowID(Main_Window\ID)) 350 | ;EndIf 351 | 352 | ;PostEvent(#PB_Event_SizeWindow, *Window\ID, 0) 353 | 354 | ProcedureReturn *Window 355 | EndProcedure 356 | 357 | Procedure Delete(*Window.Object) 358 | Protected i 359 | Protected Window.i 360 | 361 | If Not *Window 362 | ProcedureReturn #False 363 | EndIf 364 | 365 | UnbindEvent(#PB_Event_ActivateWindow, @Event_ActivateWindow(), *Window\ID) 366 | UnbindEvent(#PB_Event_MaximizeWindow, @Event_MaximizeWindow(), *Window\ID) 367 | UnbindEvent(#PB_Event_MinimizeWindow, @Event_MinimizeWindow(), *Window\ID) 368 | UnbindEvent(#PB_Event_RestoreWindow, @Event_RestoreWindow(), *Window\ID) 369 | 370 | ;If *Window\MDI_Window 371 | ; For i = 0 To CountTabBarGadgetItems(Main_Window\Panel) - 1 372 | ; If GetTabBarGadgetItemData(Main_Window\Panel, i) = *Window\ID 373 | ; RemoveTabBarGadgetItem(Main_Window\Panel, i) 374 | ; Break 375 | ; EndIf 376 | ; Next 377 | ;EndIf 378 | 379 | Window = *Window\ID 380 | 381 | If ChangeCurrentElement(Object(), *Window) 382 | DeleteElement(Object()) 383 | EndIf 384 | 385 | D3docker::Window_Close(Window) 386 | 387 | ProcedureReturn #True 388 | EndProcedure 389 | 390 | Procedure Init(Parent_Window, Docker, StatusBar) 391 | Main\Parent_Window = Parent_Window 392 | Main\Docker = Docker 393 | Main\StatusBar = StatusBar 394 | EndProcedure 395 | 396 | EndModule 397 | 398 | ; IDE Options = PureBasic 5.31 (Windows - x64) 399 | ; CursorPosition = 313 400 | ; FirstLine = 293 401 | ; Folding = --- 402 | ; EnableUnicode 403 | ; EnableXP -------------------------------------------------------------------------------- /Includes/ZLib.pbi: -------------------------------------------------------------------------------- 1 | DeclareModule ZLIB 2 | ; zlib.h -- Interface of the 'zlib' general purpose compression library 3 | ; version 1.2.8, April 28th, 2013 4 | ; 5 | ; Copyright (C) 1995-2013 Jean-loup Gailly And Mark Adler 6 | ; 7 | ; This software is provided 'as-is', without any express Or implied 8 | ; warranty. In no event will the authors be held liable For any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted To anyone To use this software For any purpose, 12 | ; including commercial applications, And To alter it And redistribute it 13 | ; freely, subject To the following restrictions: 14 | ; 15 | ; 1. The origin of this software must Not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is Not required. 19 | ; 2. Altered source versions must be plainly marked As such, And must Not be 20 | ; misrepresented As being the original software. 21 | ; 3. This notice may Not be removed Or altered from any source distribution. 22 | ; 23 | ; Jean-loup Gailly Mark Adler 24 | ; jloup@gzip.org madler@alumni.caltech.edu 25 | ; 26 | ; 27 | ; The Data format used by the zlib library is described by RFCs (Request For 28 | ; Comments) 1950 To 1952 in the files http://tools.ietf.org/html/rfc1950 29 | ; (zlib format), rfc1951 (deflate format) And rfc1952 (gzip format). 30 | 31 | #ZLIB_VERSION = "1.2.8" 32 | #ZLIB_VERNUM = $1280 33 | #ZLIB_VER_MAJOR = 1 34 | #ZLIB_VER_MINOR = 2 35 | #ZLIB_VER_REVISION = 8 36 | #ZLIB_VER_SUBREVISION = 0 37 | 38 | ; The 'zlib' compression library provides in-memory compression And 39 | ; decompression functions, including integrity checks of the uncompressed Data. 40 | ; This version of the library supports only one compression method (deflation) 41 | ; but other algorithms will be added later And will have the same stream 42 | ; Interface. 43 | ; 44 | ; Compression can be done in a single Step If the buffers are large enough, 45 | ; Or can be done by repeated calls of the compression function. In the latter 46 | ; Case, the application must provide more input And/Or consume the output 47 | ; (providing more output space) before each call. 48 | ; 49 | ; The compressed Data format used by Default by the in-memory functions is 50 | ; the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 51 | ; around a deflate stream, which is itself documented in RFC 1951. 52 | ; 53 | ; The library also supports reading And writing files in gzip (.gz) format 54 | ; With an Interface similar To that of stdio using the functions that start 55 | ; With "gz". The gzip format is different from the zlib format. gzip is a 56 | ; gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 57 | ; 58 | ; This library can optionally Read And write gzip streams in memory As well. 59 | ; 60 | ; The zlib format was designed To be compact And fast For use in memory 61 | ; And on communications channels. The gzip format was designed For single- 62 | ; file compression on file systems, has a larger header than zlib To maintain 63 | ; directory information, And uses a different, slower check method than zlib. 64 | ; 65 | ; The library does Not install any signal handler. The decoder checks 66 | ; the consistency of the compressed Data, so the library should never crash 67 | ; even in Case of corrupted input. 68 | 69 | ; #### Information about the data types: 70 | ; #### On x64 Windows LLP64 is used. on x64 Linux and MacOS X LP64 is used. The x86 version of Windows, Linux and MacOS use ILP32. Therefore: 71 | ; ╔══════╤══════════╤═════════════════╗ 72 | ; ║ │ Windows │ Linux, MacOS ║ 73 | ; ║ │ ├────────┬────────╢ 74 | ; ║ │ x86, x64 │ x86 │ x64 ║ 75 | ; ╟──────┼──────────┼────────┼────────╢ 76 | ; ║ int │ 32 bit │ 32 bit │ 32 bit ║ 77 | ; ╟──────┼──────────┼────────┼────────╢ 78 | ; ║ long │ 32 bit │ 32 bit │ 64 bit ║ 79 | ; ╚══════╧══════════╧════════╧════════╝ 80 | ; #### In zlib uInt is defined as "unsigned int" and uLong as "unsigned long". 81 | Macro C_int : l : EndMacro 82 | Macro C_uInt : l : EndMacro 83 | CompilerIf #PB_Compiler_OS = #PB_OS_Linux Or #PB_Compiler_OS = #PB_OS_MacOS 84 | Macro C_long : i : EndMacro 85 | Macro C_uLong : i : EndMacro 86 | CompilerElse 87 | Macro C_long : l : EndMacro 88 | Macro C_uLong : l : EndMacro 89 | CompilerEndIf 90 | 91 | Structure z_stream Align #PB_Structure_AlignC ; SizeOf_x64(z_stream) = 88, SizeOf_x86(z_stream) = 56 92 | *next_in.Byte ; next input byte 93 | avail_in.C_uInt ; number of bytes available at next_in 94 | total_in.C_uLong ; total nb of input bytes read so far 95 | 96 | *next_out.Byte ; next output byte should be put there 97 | avail_out.C_uInt ; remaining free space at next_out 98 | total_out.C_uLong ; total nb of bytes output so far 99 | 100 | *msg ; last error message, NULL if no error 101 | *state ; not visible by applications 102 | 103 | *zalloc ; used to allocate the internal state 104 | *zfree ; used to free the internal state 105 | *opaque ; private data object passed to zalloc and zfree 106 | 107 | data_type.C_int ; best guess about the data type: binary or text 108 | adler.C_uLong ; adler32 value of the uncompressed data 109 | reserved.C_uLong ; reserved for future use 110 | EndStructure 111 | 112 | ; gzip header information passed To And from zlib routines. See RFC 1952 113 | ; For more details on the meanings of these fields. 114 | 115 | Structure gz_header Align #PB_Structure_AlignC ; SizeOf_x64(gz_header) = 72, SizeOf_x86(gz_header) = 52 116 | text.C_int ; true if compressed data believed to be text 117 | time.C_uLong ; modification time 118 | xflags.C_int ; extra flags (not used when writing a gzip file) 119 | os.C_int ; operating system 120 | *extra ; pointer to extra field or Z_NULL if none 121 | extra_len.C_uInt; extra field length (valid if extra != Z_NULL) 122 | extra_max.C_uInt; space at extra (only when reading header) 123 | *name ; pointer to zero-terminated file name or Z_NULL 124 | name_max.C_uInt ; space at name (only when reading header) 125 | *comment ; pointer to zero-terminated comment or Z_NULL 126 | comm_max.C_uInt ; space at comment (only when reading header) 127 | hcrc.C_int ; true if there was or will be a header crc 128 | done.C_int ; true when done reading gzip header (not used when writing a gzip file) 129 | EndStructure 130 | 131 | Structure gzFile : EndStructure 132 | 133 | ; The application must update next_in And avail_in when avail_in has dropped 134 | ; To zero. It must update next_out And avail_out when avail_out has dropped 135 | ; To zero. The application must initialize zalloc, zfree And opaque before 136 | ; calling the init function. All other fields are set by the compression 137 | ; library And must Not be updated by the application. 138 | ; 139 | ; The opaque value provided by the application will be passed As the first 140 | ; parameter For calls of zalloc And zfree. This can be useful For custom 141 | ; memory management. The compression library attaches no meaning To the 142 | ; opaque value. 143 | ; 144 | ; zalloc must Return Z_NULL If there is Not enough memory For the object. 145 | ; If zlib is used in a multi-Threaded application, zalloc And zfree must be 146 | ; thread safe. 147 | ; 148 | ; On 16-bit systems, the functions zalloc And zfree must be able To allocate 149 | ; exactly 65536 bytes, but will Not be required To allocate more than this If 150 | ; the symbol MAXSEG_64K is Defined (see zconf.h). WARNING: On MSDOS, pointers 151 | ; returned by zalloc For objects of exactly 65536 bytes *must* have their 152 | ; offset normalized To zero. The Default allocation function provided by this 153 | ; library ensures this (see zutil.c). To reduce memory requirements And avoid 154 | ; any allocation of 64K objects, at the expense of compression ratio, compile 155 | ; the library With -DMAX_WBITS=14 (see zconf.h). 156 | ; 157 | ; The fields total_in And total_out can be used For statistics Or progress 158 | ; reports. After compression, total_in holds the total size of the 159 | ; uncompressed Data And may be saved For use in the decompressor (particularly 160 | ; If the decompressor wants To decompress everything in a single Step). 161 | 162 | ; ######################### 163 | ;- constants 164 | ; ######################### 165 | 166 | #Z_NO_FLUSH = 0 167 | #Z_PARTIAL_FLUSH = 1 168 | #Z_SYNC_FLUSH = 2 169 | #Z_FULL_FLUSH = 3 170 | #Z_FINISH = 4 171 | #Z_BLOCK = 5 172 | #Z_TREES = 6 173 | ; Allowed flush values; see deflate() and inflate() below for details 174 | 175 | #Z_OK = 0 176 | #Z_STREAM_END = 1 177 | #Z_NEED_DICT = 2 178 | #Z_ERRNO = -1 179 | #Z_STREAM_ERROR = -2 180 | #Z_DATA_ERROR = -3 181 | #Z_MEM_ERROR = -4 182 | #Z_BUF_ERROR = -5 183 | #Z_VERSION_ERROR = -6 184 | ; Return codes For the compression/decompression functions. Negative values 185 | ; are errors, positive values are used For special but normal events. 186 | 187 | #Z_NO_COMPRESSION = 0 188 | #Z_BEST_SPEED = 1 189 | #Z_BEST_COMPRESSION = 9 190 | #Z_DEFAULT_COMPRESSION = -1 191 | ; compression levels 192 | 193 | #Z_FILTERED = 1 194 | #Z_HUFFMAN_ONLY = 2 195 | #Z_RLE = 3 196 | #Z_FIXED = 4 197 | #Z_DEFAULT_STRATEGY = 0 198 | ; compression strategy; see deflateInit2() below for details 199 | 200 | #Z_BINARY = 0 201 | #Z_TEXT = 1 202 | #Z_ASCII = #Z_TEXT ; For compatibility With 1.2.2 And earlier 203 | #Z_UNKNOWN = 2 204 | ; Possible values of the data_type field (though see inflate()) 205 | 206 | #Z_DEFLATED = 8 207 | ; The deflate compression method (the only one supported in this version) 208 | 209 | #Z_NULL = 0 ; For initializing zalloc, zfree, opaque 210 | 211 | ImportC "zlib.lib" 212 | zlibVersion () ; Returns a pointer to a string 213 | deflateInit_ (*stream.z_stream, level, *version_string, stream_size) 214 | deflate (*stream.z_stream, flush) 215 | deflateEnd (*stream.z_stream) 216 | 217 | inflateInit_ (*stream.z_stream, *version_string, stream_size) 218 | inflate (*stream.z_stream, flush) 219 | inflateEnd (*stream.z_stream) 220 | 221 | deflateInit2_ (*stream.z_stream, level, method, windowBits, memLevel, strategy, *version_string, stream_size) 222 | deflateSetDictionary (*stream.z_stream, *dictionary, dictLength) 223 | deflateCopy (*dest.z_stream, *source.z_stream) 224 | deflateReset (*stream.z_stream) 225 | deflateParams (*stream.z_stream, level, strategy) 226 | deflateTune (*stream.z_stream, good_length, max_lazy, nice_length, max_chain) 227 | deflateBound (*stream.z_stream, sourceLen) 228 | deflatePending (*stream.z_stream, *pending, *bits) 229 | deflatePrime (*stream.z_stream, bits, value) 230 | deflateSetHeader (*stream.z_stream, *head.gz_header) 231 | 232 | inflateInit2_ (*stream.z_stream, windowBits, *version_string, stream_size) 233 | inflateSetDictionary (*stream.z_stream, *dictionary, dictLength) 234 | inflateGetDictionary (*stream.z_stream, *dictionary, *dictLength.Long) 235 | inflateSync (*stream.z_stream) 236 | inflateCopy (*dest.z_stream, *source.z_stream) 237 | inflateReset (*stream.z_stream) 238 | inflateReset2 (*stream.z_stream, windowBits) 239 | inflatePrime (*stream.z_stream, bits, value) 240 | inflateMark (*stream.z_stream) 241 | inflateGetHeader (*stream.z_stream, *head.gz_header) 242 | inflateBackInit (*stream.z_stream, windowBits, *window) 243 | inflateBack (*stream.z_stream, *in, *in_desc, *out, *out_desc) 244 | inflateBackEnd (*stream.z_stream) 245 | 246 | zlibCompileFlags () 247 | 248 | compress (*dest, *destLen, *source, sourceLen) 249 | compress2 (*dest, *destLen, *source, sourceLen, level) 250 | compressBound (sourceLen.l) 251 | 252 | uncompress (*dest, *destLen, *source, sourceLen) 253 | 254 | gzopen (path.s, mode.s) 255 | gzdopen (fd, mode.s) 256 | gzbuffer (*file.gzFile, size) 257 | gzsetparams (*file.gzFile, level, strategy) 258 | gzread (*file.gzFile, *buf, len) 259 | gzwrite (*file.gzFile, *buf, len) 260 | gzprintf (*file.gzFile, format.s, text.s) 261 | gzputs (*file.gzFile, s.s) 262 | gzgets (*file.gzFile, *buf, len) 263 | gzputc (*file.gzFile, c) 264 | gzgetc (*file.gzFile) 265 | gzungetc (c, *file.gzFile) 266 | gzflush (*file.gzFile, flush) 267 | gzseek (*file.gzFile, offset, whence) 268 | gzrewind (*file.gzFile) 269 | gztell (*file.gzFile) 270 | gzoffset (*file.gzFile) 271 | gzeof (*file.gzFile) 272 | gzdirect (*file.gzFile) 273 | gzclose (*file.gzFile) 274 | gzclose_r (*file.gzFile) 275 | gzclose_w (*file.gzFile) 276 | gzerror (*file.gzFile, *errnum) 277 | gzclearerr (*file.gzFile) 278 | 279 | adler32 (adler.l, *buf, len.l) 280 | adler32_combine (adler1.l, adler2.l, len2) 281 | crc32 (crc.l, *buf, len.l) 282 | crc32_combine (crc1.l, crc2.l, len2) 283 | EndImport 284 | 285 | ; deflateInit And inflateInit are macros To allow checking the zlib version 286 | ; And the compiler's view of z_stream: 287 | 288 | Macro deflateInit(strm, level) 289 | ZLIB::deflateInit_((strm), (level), ZLIB::zlibVersion(), SizeOf(ZLIB::z_stream)) 290 | EndMacro 291 | 292 | Macro inflateInit(strm) 293 | ZLIB::inflateInit_((strm), (level), (method), (windowBits), (memLevel), (strategy), ZLIB::zlibVersion(), SizeOf(ZLIB::z_stream)) 294 | EndMacro 295 | 296 | Macro deflateInit2(strm, level, method, windowBits, memLevel, strategy) 297 | ZLIB::deflateInit2_((strm), ZLIB::zlibVersion(), SizeOf(ZLIB::z_stream)) 298 | EndMacro 299 | 300 | Macro inflateInit2(strm, windowBits) 301 | ZLIB::deflateInit2_((strm), (windowBits), ZLIB::zlibVersion(), SizeOf(ZLIB::z_stream)) 302 | EndMacro 303 | 304 | Macro inflateBackInit(strm, windowBits, window) 305 | ZLIB::inflateBackInit_((strm), (windowBits), (window), ZLIB::zlibVersion(), SizeOf(ZLIB::z_stream)) 306 | EndMacro 307 | 308 | EndDeclareModule 309 | 310 | Module ZLIB 311 | 312 | EndModule 313 | ; IDE Options = PureBasic 5.40 LTS (Windows - x64) 314 | ; CursorPosition = 240 315 | ; Folding = -- 316 | ; EnableXP 317 | ; DisableDebugger 318 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | D3hex 2 | ===== 3 | 4 | D3hex is a fast and lightweight hex-editor. 5 | To be more exact it grew to be a general binary file-editor and viewer, which includes a hex-editor among other things. 6 | The goal of the software is to faciliate you with the tools to open, interpret, view and edit any file you wish. 7 | One important element of this software is its node based approach. 8 | This means that all functions of the software are available as single nodes, which can be combined to fulfil a specific task. 9 | 10 | **Examples of nodes are:** 11 | - Sources (A file, random data) 12 | - Hex-editor 13 | - Viewer (Graphs, image viewer) 14 | - And many more 15 | 16 | In a very simple case you just connect a source to the hex-editor node. This could look similar to this: 17 | ![](/Screenshots/Nodes_Simple.png) 18 | The "History" node is used to virtualize all operations made by the "Editor" node. 19 | This allows undo and redo operations, until you finally press "save". 20 | Without the "History" node, you would write directly into the "File". 21 | 22 | ## Features 23 | - "Unlimited" datasize ( ~ 9.2 Exabytes) 24 | - Max. filesize isn't limited to RAM 25 | - Insert and delete operation 26 | - Search and replace binary data, integers, floats, strings 27 | - Open and edit virtual memory of processes 28 | - Network terminal to communicate with any TCP or UDP based server 29 | - Checksum and hashcode calculator 30 | - Display data as graph or image 31 | - Binary operation of two data sources (XOR, AND, OR) 32 | - Data inspector (Integers, floats, strings) 33 | 34 | ## Future 35 | - Node to compress and decompress zlib and/or gzip streams 36 | - Node for statistics (Histogram, Entropy, Mean, ...) 37 | - Node for math operations 38 | - Basic math 39 | - Crosscorrelation, Autocorrelation, Discrete Fourier Transformation, ... 40 | - Disassembler (Capstone) 41 | - Audioplayback 42 | - Node to de- and encode common file formats (mp3, jpeg, png, ...) 43 | - Physical or logical drives as data source 44 | - Wavegenerator (Sine, Square, Triangle, ...) 45 | - Node to compare binary data 46 | - Text editor 47 | - Clipboard as data source 48 | 49 | ## Language 50 | The software is completely written in [PureBasic](http://www.purebasic.com), which produces lightweight and native 32-bit and 64-bit applications. 51 | It is planned to implement a plugin system, which allows to extend the available nodes. 52 | In this case it would be possible to contribute in any language, which can compile c like shared libraries (.dll files on Windows, .so files on Linux). 53 | Soon it will be possible to create custom nodes with the Julia scripting language as well. 54 | 55 | ## License 56 | D3hex is released under the [GPL](/LICENSE). 57 | 58 | ## Screenshots 59 | ![](/Screenshots/4.png) 60 | ![](/Screenshots/1.png) 61 | ![](/Screenshots/3.png) 62 | -------------------------------------------------------------------------------- /Screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/1.png -------------------------------------------------------------------------------- /Screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/2.png -------------------------------------------------------------------------------- /Screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/3.png -------------------------------------------------------------------------------- /Screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/4.png -------------------------------------------------------------------------------- /Screenshots/4_Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/4_Small.png -------------------------------------------------------------------------------- /Screenshots/Nodes_Simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/Nodes_Simple.png -------------------------------------------------------------------------------- /Screenshots/Object_Binary_Operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/Object_Binary_Operation.png -------------------------------------------------------------------------------- /Screenshots/Object_Copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/Object_Copy.png -------------------------------------------------------------------------------- /Screenshots/Object_Datatypes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/Object_Datatypes.png -------------------------------------------------------------------------------- /Screenshots/Open_File.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dadido3/D3hex/9348bda8f83b6d2d3f279f48411cde29b5457692/Screenshots/Open_File.png --------------------------------------------------------------------------------