Asset - Scripts [BUFFERS] xBufferViewer is a GUI for buffers (v1.0.1) (FREE)

[LINKS]



[SCREENSHOTS]

xBuffers_forum_edit.jpg

[INFORMATION]

This asset is composed by a BufferViewer structure (new in GMS2.3) that allow for visualising/selecting/copying buffer contents. The viewer GUI is fully customisable, implements rows/columns names, scrollbar and autoscroll on selection drag.

[FUNCTIONS]

In the examples - bViewer - represents an instance of the BufferViewer structure.

Code:
bViewer.openFile(filename);
This function opens and loads a binary file asynchronously into a default buffer to be rendered in the bufferViewer. The created buffer will be using a default type of "buffer_fast".

Code:
bViewer.copySelection();
This function returns a copy of the current selection as a byte array.

Code:
bViewer.refresh();
This function will force a refresh of the display. This is an important function as it will refresh the surface used by the viewer.

NOTE: As it is the code doesn't require you to call it at all. But if you want to change the underlying code and increase functionality take into consideration that you might need to force the redraw by calling this function.

Code:
bViewer.drawColumnName(x, y, columnIndex);
bViewer.drawCharValue(x, y, byte, rawIndex);
bViewer.drawHexValue(x, y, byte, rawIndex);
bViewer.drawRowName(x, y, lineStartIndex);
bViewer.drawScrollbar(x1, y1, x2, y2, scrollAmount);
This set of functions is responsible for the drawing of each one of the components of the BufferViewer. These determine the GUI style used and are "virtual" methods which means they can be override to accommodate for your likings.

Code:
bViewer.scrollUp();
bViewer.scrollDown();
bViewer.mouseClick();
bViewer.mouseHold();
bViewer.asyncSaveLoad();
bViewer.draw();
These functions are called "event" methods. They bind the GMS2 event system to the BufferViewer GUI structure. They should be called in the respective object event of the using instance.

NOTE: The sample code includes a fully documented object with all the setup done for you so you can read the code and understand where everything should go.

Code:
bViewer.setBuffer(buffer);
This function will set the viewer target buffer to an already existing buffer (this function can be used instead of openFile if you want to load the buffer manually).

Code:
bViewer.setFont(font);
This is the function used to set the font that BufferViewer will use to render the data to the screen.

Code:
bViewer.setSize(width, height);
bViewer.setWidth(width)
bViewer.setHeight(height);
These functions are used to set the BufferViewer dimensions.

NOTE: The code automatically manages the number of columns and rows, taking into account the font, width and height.

Code:
bViewer.setPosition(x, y);
This is the function used to set the position of the BufferViewer GUI on screen. It can use both screen/room coordinates depending on where you call the draw function (see below).

Code:
bViewer.setRowNameWidth(width);
This is the function sets the width of the column containing the row names.

Code:
bViewer.setScrollSensitivity(value);
This is the function used to set the auto scroll (selection drag) sensitivity [0-1].

Code:
bViewer.setScrollStep(font);
This is the function used to set the scroll (mouse wheel) step.

Code:
bViewer.setSelection(start, end);
This is the function allows for manually setting the selection of the BufferViewer where "start" and "end" are buffer byte indexes.

Code:
bViewer.getDeactivatedColor(); // can override
bViewer.getActivatedColor(); // can override
bViewer.getTellColor(); // can override
bViewer.getHexGridOffset(); // can override (v1.0.1)
bViewer.getCharGridOffset(); // can override (v1.0.1)
bViewer.getScrollBarOffset(); // can override (v1.0.1)
bViewer.getTopRow();
bViewer.getColumns();
bViewer.getRows();
bViewer.getMaxRows();
This last set of functions are almost always used internally but can be useful while overriding existing methods. The "get*Color" functions only return a fixed value and can be override to your liking. The "get*Offset" functions are responsible for component positioning and can also be override (the offset corresponds to the offset on the X coordinate of the component from the left side edge of the viewer).

[SAMPLE PROJECT]

Included is a sample project that consists of a code example completely documented where some functionality is being used.

[BONUS]

Included with the project is a font created by JetBrains. JetBrains Mono typeface is available under the SIL Open Font License 1.1 license and can be used free of charge, for both commercial and non-commercial purposes.


[COMPATIBILITY]

The asset is fully compatible with 2.3+ and is purely written in GML making it compatible with all exports available.

[CHANGE LOG]

v1.0.1
Added component placement edit and back selection.
 
Last edited:
[CHANGE LOG]

v1.0.1
Added component placement edit and back selection.


[NEW FUNCTIONS]

Code:
bViewer.getHexGridOffset(); // can override
bViewer.getCharGridOffset(); // can override
bViewer.getScrollBarOffset(); // can override
The "get*Offset" functions are responsible for component positioning and can also be override (the offset corresponds to the offset on the X coordinate of the component from the left side edge of the viewer).
 
Last edited:
Top