Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Pro Tip: Bitmap Fonts + Widgets + Modular Code + Working Demo

Author
Message
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 23rd Oct 2017 05:27 Edited at: 22nd May 2024 20:47
Mage's Modular Programming Demo - Widgets


Preface.
What if making excellent menu systems was as easy as a single command, and you also had access to the code?

Several weeks ago I posted about my desire to expand on previous examples of reusable generic functions. I mentioned that a core set of functions could be created, highly polished that allow new programs to be written with excellent complex features and little to no work needed because of reusable code. Well it turns out that I've been working on this for a few weeks. Previously I released a Bitmap Font framework called BFont. https://forum.thegamecreators.com/thread/207584. I have used this as a foundation and expanded the work fixing bugs, adding features, and most importantly adding GUI Widgets like lists and buttons. I have long had issues when writing programs where I would need to list information like file names, or have buttons, or other controls. These things always need to be rewritten, they were never consistent, took a lot of time, looked terrible, and offered minimal functionality. What if I could create a 100% functional button with one command? Or a list? This demo is just that. It is a series of functions that allow people to create Buttons, Button Lists, Graphical Image Buttons, Dialogs, Lists, Radio Buttons, Check-boxes, and Textboxes all with one command. Everything is very polished and featured, ties into the Bitmap Font system, and is accessible and expandable since the source is right there. I have decided to release this as a demo presentation in part as a way for me to push me to polish this framework to a high level.

I also mentioned the difficulty of handling text input. I have long used some reusable functions to accept text input, where functionality was minimal. You could see characters you could type, backspace was supported, and only one of the enter buttons was supported. For this demo I have gone all out. The textbox widget in this demo attempts to replicate most of the features of a windows textbox. There is mouse support, both enter buttons are supported, you can seek and edit the middle of text, home/del/end keys are supported and most impressively autocomplete has been implemented. I mentioned this should be possible when I talked about this several weeks ago. Here it has been implemented. If the feature is active then the textbox will break sentences apart and remember words, and store those words in a dictionary file. When you type the textbox will offer autocomplete suggestions.

I feel this work will put to rest some longstanding pains I have had making apps like editors and menus.
I will attach a downloadable demo with the full code and media (the bitmap font uses images).


Lists - Problem solved. Permanently.


I started with making a fully functional list widget. You can see that there is full mouse support. The scroll and selection is completely there. Also an important detail is that through this entire demo mouse clicking activates on release not press. This makes all of the controls very nice to use. Have you ever tried to list a bunch of stuff on the screen only to have them scroll off the screen? Does it look ugly? Wierd controls to select stuff? Long confusing code? This fixes that. You can basically setup a list with one command and there's a bunch of simple controls like in visual basic. You can also easily sort and search the list with one command.


Dialog Boxes and Bitmap Fonts.


I released a bitmap font system BFont. This is MFont, and updated expanded version. This solves a major problem with most other font systems. Professional games don't install windows fonts, and don't use them. MFont allows you to ensure in a simple way text looks the same on all computers. It also gives you some extra control and conveniences. The dialog box in this shot is a single widget with 2 buttons built in. This is useful for an Ok/Cancel dialog or something like that.


Radio Buttons, Check Boxes, Button Lists and Color Themes.


It's probably a good idea to have some more robust controls than buttons. So I implemented Button Lists which are buttons where identical sized buttons can be easily added below on the screen. This is good for menus. Then I added radio buttons which are a list of buttons where only one of the buttons is allowed to be active at a time. Finally I implemented check boxes which look like radio buttons but there's no rule about one being active at a time. All of these use consistent styles and controls. They are all single command creation and use. Also seen here is color theme support. All of the controls and control text have a common color system. This enables very quick and easy changing of the entire color theme.


Text Boxes and Autocomplete.


While I am pleased at doing a good job with lists, I am also very pleased with this work. So the textbox has an editing cursor and mouse support. You can click to place the cursor or use arrow keys including Home/End. This is a big deal, I've always had to delete a whole sentence if I was typing something and made a mistake. Both enter keys are supported and Del/Backspace are too. You'll also see here that the textbox has an autocomplete feature. Basically if the feature is active and if you have a dictionary.txt file in the main directory of your program, the textbox will suggest words from that dictionary file. When you type the ghosted suggestion will appear. If you press spacebar it will autocomplete. If you press the delete key the autocomplete will disappear in case you need to type a space instead of autocomplete.


CPU Friendly Framerate Limiter.

This framework and the demos all use a cpu friendly framerate limiter. This allows the program to run capped at 60 fps (or other rates) and the program will only use 1% of the cpu instead of 100% at all times no matter what. This will allow apps to save battery life, and keeps fans quieter. Basically the framework wraps SYNC in a function where this extra functionality can be tacked on. This is also done since I plan on adding in easier controls for controlling multiple cameras and the SYNC MASK command which is always a pain to deal with. Also I have a crash prevention system which is not included in this framework since it would make things confusing. It's better to include the wrapper now rather than convert every program for it later. So I decided to throw in the SYNC command wrapper with CPU friendly frame limiter. I think this will help people greatly.
This is based on this previous tip:
https://forum.thegamecreators.com/thread/202812


Extra Details...
This issue was resolved in update 3.
The bitmap font system was fast but not as fast as regular screen text. So for MFont I explored using Image Kit but there were technical limitations that made using it problematic. Instead I wrote a caching system where text that is written to the screen a lot (consider your game is probably drawing 30 or 60 frames per second) the text would be converted into an image and merely pasted automatically on the fly. I found that this approach along with the necessary overhead was only 10-20% faster than using sprites for each letter. Additionally the initial conversion process to turn a recolored, scaled, u/v adjusted, 8bit transparent, string of sprites into a single image was too slow to be useful in most situations. The caching effect would generate a single nearly 500ms lag spike. While a single lag spike like this might be excusable in some situations, it kills the program if lots of changing text is on the screen. This functionality is still included in the demo. You can activate/deactivate this by setting mfont_fastdrawenabled to 1 or 0. I wanted it to work and be a higher profile inclusion but its not suitable for prime time.

The code for converting a recolored, scaled, u/v adjusted, 8bit transparent, string of sprites into a single image is shown here:

Based on my previous post here:
https://forum.thegamecreators.com/thread/184514


Notable Exclusions.
Issue resolved in update 3.
Issue resolved in update 4.
I probably should have included a progress bar. Shameful, it would only take about an hour to program it in as a widget. I might update with it. I also plan to make a File Load and File Save widget that is a "Meta" widget. So creating a file load widget automatically creates a list for folders, a list for files, some buttons, and handles the functionality. Then when the user finally picks a file, the entire "Meta" widget activates (in the same sense a button would when pressed), so the function drawing the file load widget detects the activation and can then grab the picked file, delete the widget, and move on to actually loading the file. So the entire file loading process becomes 1 command and fairly trivial. No need to concern yourself with a menu system or navigating folders. Since its a 1 command draw, you can even add in extra functionality like previewing what ever the file load widget is currently selecting before it "activates" with the users picked file. Anyway that might be an update. I will be doing this.


Requirements.
1. Dark Basic Professional - Latest Version
https://forum.thegamecreators.com/thread/180294

2. Advanced 2D Plugin
https://forum.thegamecreators.com/thread/179096


Feel free to comment, complain, dissect, suggest, ask, and talk.
Working Demo Source Code - Attached to this post!


Previous modular code discussion:
https://forum.thegamecreators.com/thread/220626

Interested in converting other fonts into this system? Here's the tool:
https://forum.thegamecreators.com/thread/189225

See my previous tip here...
https://forum.thegamecreators.com/thread/207584

Update 3 - Oct 25 2017 - Adds Progress Bars, Fast Draw, Image Text, Camera Mask Management, Frame Limiter Controls.
Update 4 - Oct 27 2017 - Adds File Load Dialogs, File Save Dialogs, Basic Panels, and an example for Graphical Buttons.
Update 5 - Oct 31 2017 - Adds Unlimited widgets and list sizes, help documentation, debug panel, and bug fixes.
Update 6 - Nov 15 2017 - Adds Multi-Line Text/TextBoxes, Drop Down Lists, Bitmap Font Patches, Bug fixes.
Update 6.1 - Nov 20 2017 - Bug fixes. Patches to Button Lists, Debug Menu, Textbox caption changing, help documentation.
Update 6.2 - Dec 4 2017 - Bug fixes. Mouse right click activate when released now works correctly.
Update 6.3 - Feb 9 2018 - Mouse middle click added, enhanced multiple font support, tweaked auto-complete min 5 characters or more.
Update 6.4 - Mar 4 2018 - Enhanced File Load/Save dialogs with folders/drives support. Fixed related bugs.
Update 6.5 - April 7 2018 - Added support for inline color codes for text.
Update 6.5.2 - July 6 2018 - Bug Fixes. Added support for removing entries from lists.
Update 6.5.4 - October 5 2018 - Bug Fixes. Added support for text links.
Update 6.5.5 - Jan 7 2021 - Fixed Dictionary Hard limit Crash. Bug Fixes with List sorting. Bug Fixes with MFont Character Limit Calc and Inline Color.
Update 6.5.6 - Jan 21 2021 - Bug fix with list scroll bar that required mouse to remain within the bar. Other minor bug fixes.
Update 6.5.7 - Feb 14 2022 - Bug fix with deleted textboxes not deleting entirely. Added Condense function to Lists.
Update 6.5.8 - Feb 15 2022 - Added SetRaw function to progress bars. Sets progress, skips animation. Fixed crash on multiple panels created.
Update 6.5.9 - Mar 2 2022 - Added MImgButton to documentation, and corrected some errors. Added Initialization Loading screen.
Update 6.7.2 - Sept 20 2022 - Added tree lists and inline text icons, corrected crash errors with various controls, updated documentation.
Update 6.7.3 - Sept 22 2022 - Fixed bug with progress bar animations. More accurate, fluid, less jumpy.
Update 6.7.4 - July 17 2023 - Fixed bug with File Save dialog not selecting a file.
Update 6.7.5 - May 22 2024 - Added Color Palette, fixed bug where dictionary would overflow and crash.

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!

Attachments

Login to view attachments
Sedit
7
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 23rd Oct 2017 06:10
Bravo my dude, I was just sitting back attempting to make a UDI for a simple evolution sim I have been working on so I could see what results other could get out of the Simple Neural net I engineered and something like this is ideal. I was just sitting back and thinking earlier, "well I guess its time to break my code into modules because I have to make some button functions and it would get to complex to be understood as a single standalone DBA.

Thank you so much mage, I am about to post V1.0 tomorrow but 2.0 might just have to borrow some of this since I love the idea of scrolls and what not. I want to be able to save the state of the Neural weights and being able to scroll through the files is just so much more professional looking.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 23rd Oct 2017 06:25 Edited at: 23rd Oct 2017 08:55
Thanks. Mentioning that is good positive encouragement.
I will probably update this with Load and Save file controls later this week as mentioned. Probably a progress bar also.

Edit: I patched a last minute bug with the textbox mouse support. Re-uploaded the attached file.
Kafoolwho
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location: The Deep
Posted: 24th Oct 2017 10:37
Hey Mage. It's good to see you back with a new "pro tip". This series of yours has provided plenty of useful tips and tricks that I have added to my own projects and experiments. And your latest addition is awesome with many possibilities. Loving the text box option!
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 25th Oct 2017 01:00
Thanks it's great to know people actually use these these demonstrations and techniques. I'm glad I'm not wasting my time posting it.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 25th Oct 2017 05:02
Nice work on the scroll box list, that's something I've been meaning to do seems like forever now.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 25th Oct 2017 07:32 Edited at: 25th Oct 2017 08:16
Content Update 3
Progress Bars and Progress Bar Dialogs.


I said that I had left this out in the original post. I have now implemented this. I remembered I should do this at the last minute. I'm calling this a progress bar but it can just as easily be a life meter or some other useful thing.

The progress bars come in two forms. One is a progress bar without anything extra so it can be fitted into what ever interface you want. The other is a progress bar with a proper dialog. So if you just wanted a proper loading message to just appear you'd want the dialog panel there not just a naked loading bar. Both versions will use the default color theme but can be overridden.

There are 3 animation modes and both styles of progress bar support them. The first animation mode is a plain bar without animation that simply shows the progress value. The second animation mode will animate and very quickly grow/shrink to the progress value. The third animation mode is animated with a slow smooth transition between value changes. These modes accommodate situations where frame rate is high or really low. If you are loading a level, and the progress bar doesn't draw except maybe several rare times in the load process, then you need the first animation mode. Using the sweet third mode won't work since the bar will be frozen without a chance to grow to the correct level. If the frame rate is fairly high then you can use some of those frames to animate the bar pretty. The animated blinking is added because telling the user the program hasn't crashed is a blessing.


MFont - Fast Draw Mode And Converting Text To Image.


I mentioned in the original post that I had included Fast Draw Mode but it was tucked away in the guts, a flawed system that lag spiked programs. I have eliminated that latency problem. So now Fast Draw is fully implemented with additional controls and conveniences. What this means is when Fast Draw mode is enabled, the MFont bitmap font system will gradually convert text that stays on the screen to images as an automated performance enhancement. The system will flush unused images after 5 seconds. To further squeeze performance, I have also implemented a Create Image feature for MFont. This will convert text generated by this system to a simple image that can be pasted.

Image Conversion Process.


Back a few years ago I posted a technique for converting a screenshot of a character into an image of that character with the background transparent, where the characters transparency was preserved. This system uses this technique for converting sprites into images. The font system at it's core selects, sizes, colors, sets transparency, and pastes sprites into words. This is much more complicated than it seems since 8bit alpha transparency of the text needs to be preserved. If not then Fast Draw and Text Images would lose their transparency when semi transparent. I guess these two worlds just came together.

Additional Enhancements.

Shadowed Text has been completely implemented. Previously it was shadowed centered text only and not supported by Fast Draw. This has been resolved. Shadowed text exists because I found text hard to read with some backgrounds.

Camera Mask Management. You never have to mess around with Sync Mask again. Simple controls to add and remove cameras. System tracks the cameras and manages everything. Even turn this feature off.

Frame Limiter Controls - The frame limiter now has controls to turn it off or change the frame rate cap.


Upcoming Update.
File Load and File Save dialog boxes.


Reply.
Ortu wrote: "Nice work on the scroll box list, that's something I've been meaning to do seems like forever now."


Thanks this has long been a pain and every program I write it seems I had make a selectable list. This is the last time I need to do any of that. Problem solved once and for all.


One more thing... I forgot to include some font files in version 2 of the demo download. That is solved and version 3 is uploaded in place. See the original post.
zero32
8
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 25th Oct 2017 08:19
this looks really cool. thumbs up for the scrollbar and animated progress bar. i did not look at the code because i work on something similar and i don't want to steal any of your code. do you have plans on implementing multiline textboxes?
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 25th Oct 2017 09:27
zero32 wrote: "this looks really cool. thumbs up for the scrollbar and animated progress bar. i did not look at the code because i work on something similar and i don't want to steal any of your code. do you have plans on implementing multiline textboxes?"


Thanks. I am posting all of this so people will use it. Feel free to use it. I might implement multi-line textboxes next week. Already can see the dialog box and how it controls in my head. Just a matter of making it do what I want it to do.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 27th Oct 2017 04:52 Edited at: 27th Oct 2017 18:40
Content Update 4
File Load Dialogs.


Open File is great and all but there's a huge problem with actually and gracefully picking which file should be opened. There's so many issues you could write a book. You can now create a Load File Dialog with one command, and draw it with one more. The entire arduous task of getting the user to pick a file to load is solved forever. The FileLoader dialog box does basically everything it's expected to do. It can filter file extensions, traverse directories, and even handle large file counts that would otherwise hang the program. You can treat it like a button. Check and if it's activated then there's a function for getting the chosen path and file name separately. It will even tell you if the user canceled, and even that can be disabled.

Since this is a modular system I decided to have this dialog window invoke some of the controls I previously created. This was very powerful and allowed me to rapidly code what otherwise would be a much larger job. The file and folder lists inherit all of their capabilities for example.

Folders with huge amounts of files, and difficulties getting fast accurate folder/file lists in DBP. If you are reading this with some interest to see how this whole project plays out then this is for you. Maybe you can even chime in and help. So it turns out there's only one good method in DBP to get a list of folder contents and that is Perform Checklist For Files. This provides a string$ list of file and folder names without telling you which is which. This leads to the need to check each to try and determine if each entry is a file or a folder. I have seen people attempt this on these forums and often people just check to see if the string$ has a file extension in it. Probably the fastest method. However this fails and could result in crashing the program if the file has no extension or if the folder name has a period in it. This project is aimed at a high standard. So I have had to be safe and check each file with File Exist() and other methods to almost reach a proper level of certainty. This means that scanning a folder so the contents will appear in the File Load and File Save dialogs takes more time than faster more dangerous methods. So I had this File Load dialog all finished and I was testing it. It was fabulous until I navigated to a folder with hundreds of files. The program froze for a minute until the folder was scanned. That's a big problem. What happens if you are using this and you navigate to a huge folder and things freeze up. Do you wait for the program to unfreeze? How long? Do you even know you can wait? Close the program? All of your work lost? So now the File Load and File Save dialogs will very gracefully populate. You'll see a percentage appear if things are still loading and you'll still have control. So you can navigate out of that folder, load, save, or even cancel.


File Save Dialogs.


Just like the FileLoader I have created FileSaver. Again, Open to Write is great but how to you actually pick the file and location? It's a pain to do this well. This dialog box does it all and in one command. You can filter by file extension, restrict directory traversal, and even the cancel button. All of the expected refinements are there. So now you can very quickly and easily solve this problem and get to actually writing the file to disk.

I started this by simply copying the File Loader dialog. That saved a ton of work and made things very consistent. However there's a lot more complexity. The file loader only has to navigate and pick a file. For the File Saver Dialog it has to do this but I added support for saving over existing files, saving as a new file, and overwrite confirmation. So a Textbox, Yes/No dialog box needed to be added, and an extra button needed to be added. I should also point out something I didn't mention. A whole new control called MBasicButton was created since I actually needed a button control that didn't have it's own dialog window attached. Even though I saved a lot of work, it still required a lot of work to get this done.


Graphical Buttons.

This feature existed since the original posting however I never gave it a mention. It was tucked in there behind the scenes. So now I have created a mock example for this feature. What this does is allow you to pass a few sprites to an MImgButton control and the button will use those graphics and have all of the behavior and benefits of regular buttons. So they will be 1 line of code to draw and handle all of the mouse input. You could just do this yourself, but this method is much easier and simpler to work with. You only need to worry about if the button was pressed, everything else is taken care of.


Basic Empty Panels.

This is an empty box that appears on the screen. Location and dimensions are up to you. If you provide it with a caption then it will have a title bar and title. This is useful in situations where you are setting up UI that you want consistent with the color theme. This is also good since it's a simple one line draw command to get it on the screen. So if you ever needed it, you can make basic panels for non-standard UI elements. I know this seems simple and silly, but it's only silly until you need this and it's not available. Then it's a big problem. So problem solved!


Additional Enhancements.
Several controls received additions to allow captions to be changed without deleting and recreating them.

Upcoming Update.
Multi-Line Textboxes and Multi-Line Text Drawing. I will look into doing this and possibly release an update next week.
A more convenient method of upping the number of allowed controls. The current method requires ... well you can imagine. I can probably cut this down to changing one line of code.
Better documentation. A list of the commands and what they do. The less digging on your part the better.
A diagnostic panel. A command that draws a panel with some stats to the screen. This will include primarily how many controls have been created. If there was an overflow. This is helpful in managing issues with too many controls, and adjusting the limits.

Content Update 4 has been uploaded and attached to the top post!
zero32
8
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 29th Oct 2017 08:31
tl;dr because i did not sleep much the last few days, sorry...

Quote: " So it turns out there's only one good method in DBP to get a list of folder contents and that is Perform Checklist For Files."

Yes.
Quote: "often people just check to see if the string$ has a file extension in it. Probably the fastest method."

Quote: "So I have had to be safe and check each file with File Exist()"

No.

while "checklist string$(index)" command returns the file name, "checklist value a(index)" returns 0 if it's a file or 1 if it's a folder. you can double check with a file exist() after you hit the "Load" button for more stability.

a small sample code. it outputs the first 6 files found in the work folder:


i'm going to bed, good night
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 29th Oct 2017 09:00 Edited at: 29th Oct 2017 09:33
zero32 wrote: "while "checklist string$(index)" command returns the file name, "checklist value a(index)" returns 0 if it's a file or 1 if it's a folder. you can double check with a file exist() after you hit the "Load" button for more stability."

That functionality is undocumented. I will take a look at that. If it pans out then large folders will load much faster. Thanks a lot.

I just got done writing an update which will completely solve the issue of adding more widgets than the system is hard coded for. Currently the system has a hard cap of something like 20 of most widgets. So the next update will be a huge boost for usability. I don't mean simply upping the hard caps on the number of widgets. So this will be something really special.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 30th Oct 2017 01:08
I tried that out but it didn't really do much. It turns out that large folders were taking long to scan because the file and folder lists being set on Auto Sort mode. The checklist is already sorted so this step was completely necessary. The suggestion though is still good for efficiency and stability. What I would consider the proper way.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 31st Oct 2017 07:00 Edited at: 31st Oct 2017 08:37
Content Update 5
Dynamic Memory Allocation and Unlimited Lists/Widgets.

This project has had an unofficial motto. "Everyone wants the hotdog, but nobody wants to see how it's made." The entire purpose has been to once and for all solve longstanding repetitive problems, with a system that just takes care of everything efficiently. Since the beginning there has been one fundamental problem. The maximum number of widgets/controls needed to be set in advance. This required digging into the code. It was a problem that anyone using this code had to worry about. Not anymore.

This update adds support for unlimited controls and list sizes. The data structures are now dynamic. You don't have to worry about how big the lists get or how many you make. Just attach the code with an include statement and you never have to look at the programming. Just use want you want and no need to change anything. No need to try and figure things out.


Help Documentation Added.

This update adds HTML help documentation. This documentation contains a list of all of the regular use commands. This actually took me a long time to write, longer than most of the programming pieces. Anyway, there is no more need to look through the code for comments and functions.


Additional Enhancements.
Debug menu added to monitor various aspects of this system.
Fixed a number of bugs such as: Text transparency affecting widget text, FileLoad/FileSave now show parent folder name.
Removed a sorting bug that greatly slowed directory scanning. Thanks Zero32 for suggesting Check List Value A() method for further speed.
Renamed several functions to be more consistent with naming conventions.
Added several functions to flesh out functionality of controls such as: Button text and most captions can now be changed without remaking the widget.


Upcoming Update.
Multi-Line Text and Multi-Line Textbox. I guess I'll go ahead and get this done. Logical next step.

Content Update 5 has been uploaded and attached to the top post!

Attachments

Login to view attachments
zero32
8
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 2nd Nov 2017 07:31 Edited at: 2nd Nov 2017 07:39
i work on a google earth style app for world of warcraft as a fun project and i am going to use your system as the gui. i am going to document the progress and how i did it as a little tutorial to break the ice so others can start using it more easily, also as form of bug testing.
i'm just occupied for the moment because we have a professional fair(thanks google translate) in our city starting on friday and i help building a stand.

a quick screenshot of the app as it is now:
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 2nd Nov 2017 08:31 Edited at: 2nd Nov 2017 08:49
Well I am very pleased to see that this is helping people. If you do find any bugs then I would be grateful to hear about them. I have included demos of most of the features in the package, so everything has already been through a few layers of checks to make sure things are working. If there are any suggestions for features or changes by all means speak up. I can't guarantee I'll implement them but you might have some good ideas or advice. Otherwise I might be able to provide some insight into why something was done a particular way, in a helpful manner.

I will caution you, (and this is in the documentation), that Dark Basic Professional has a bug where the U/V data of all sprites is reset when some Image and Sprite commands are used. In particular when new sprites are created. This can cause the text to become garbled. If this happens simply use MFont_Reset() afterwards but before more text is to be drawn and it will clear up the problem. So like if you are loading/building a menu. I think DB Pro EX fixes this bug maybe, but I have not tested DB Pro EX with this code. I would imagine if Advanced 2D works then it would. If there were a way to read the sprite u/v coords I could probably automate this process efficiently. Otherwise it's the one thing you need to look out for.

I could probably rewrite the font system to not have this issue. I just thought of a memblock work around that would correct the issue. I'll look into that.

Also thanks for mentioning that you're making use of this project. It's great motivation.
seppgirty
FPSC Developer
15
Years of Service
User Offline
Joined: 3rd Jul 2009
Location: pittsburgh, pa.
Posted: 3rd Nov 2017 22:45
There's some really useful code here mage. I always wanted to learn how to do this stuff. Thanks for posting.
gamer, lover, filmmaker
Sedit
7
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 4th Nov 2017 06:42
So I have been a bit tied up with my own little project and not had much time to really go over your code and look it though to the level it deserves. I have gotten to a point in which I am contemplating a simple file menu bar at the top in order to Save, Load, Get stats, Options Etc...

I got ready to start coding then I thought to myself that it would almost be blasphemous to let your hard work go to waste. How do you think your system will work with something like that. On the surface it looks like it should work rather fine would be my initial guess right. What about performance since that is a HUGE issue for me right now on this dinosaur of a computer and how computationally intensive my AI system is at the moment. Would maintaining and updating these buttons and Menus draw on the system to hard if it were put in a rather intensive memory and computational loop?


Back in my DOS days I was rather good at generating menus buttons etc and with Windows being a thing now making proper graphics should be much easier with the ability to just load bitmaps on the fly and treat the buttons as sprites.

Sad to say I'm currently porting my Creatures over to VC++ because I have just pretty much maxed out the abilities of Darkbasic. So I am still going to generate an AI Library for Darkbasic based on Artificial Neural Nets and Action reaction Trigger mechanisms to maintain output so that I can still Use Darkbasic as my prototype language. It will allow me to Gain the speed I need without having to fully move away from DB.


Is this currently a Lib or any plans to make it so? Also if you ever need any help at all I wouldn't mind lending a hand here or there if needed. Like I said I was always pretty good at making 3D style buttons like windows uses in BASIC. I could let a coding finger or two in the graphics department here or there. It would be a nice change of pace since my Neural Net is giving me massive headaches the past few days. My Traditional one is sort of working but its not differentiating the 1 - 0 the way it should be hovering around .4 - .5 and I don't know why so I find it good to work on something else when my main project makes me feel like a brain aneurysm is going to burst every 5 seconds.

IDK Its a long day and Im rambling, Again nice work btw, Will it hold up well in a memory intensive loop?
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 4th Nov 2017 09:11 Edited at: 4th Nov 2017 09:47
Sedit wrote: "I have gotten to a point in which I am contemplating a simple file menu bar at the top in order to Save, Load, Get stats, Options Etc... "

This system is well suited for that.

Sedit wrote: "How do you think your system will work with something like that. On the surface it looks like it should work rather fine would be my initial guess right. What about performance since that is a HUGE issue for me right now on this dinosaur of a computer and how computationally intensive my AI system is at the moment. Would maintaining and updating these buttons and Menus draw on the system to hard if it were put in a rather intensive memory and computational loop?"

That would depend on the details. The system is quite efficient for what it does. It uses advanced2D plugin which is much faster than built-in 2d commands. If you are not putting large amounts of rapidly changing text on screen then the Fast Draw mode will further speed up text drawing by using a cache system. Controls that are not being drawn to the screen don't use cpu resources. So a File Load menu isn't going to impact you while your simulation is running.

This system immediately gives you big benefits. You can create a control with 1 command, then later in a loop you can draw and handle it's behavior all in 1 draw command, then easily check it with 1 more command. So basically a mountain of code to make a menu is reduced to a few commands and the menu works really well. For example mouse clicks that activate on release not press.

Sedit wrote: "Is this currently a Lib or any plans to make it so?."

I don't know how to turn this code into a plugin. I can code in c++ and I suppose I could if the world was at stake read into things and eventually do it. However it would probably be much much easier if someone offered suggestions or assistance since such a process would no doubt involve DBP specific information. I am not familiar with any convenient porting methods and plugin making specifically. Also I started this because I needed a system like this, and I will need to add to it here and there which makes this open concept more useful.

Sedit wrote: "... I wouldn't mind lending a hand here or there if needed. Like I said I was always pretty good at making 3D style buttons like windows uses in BASIC. I could let a coding finger or two in the graphics department here or there."

This system supports color themes. The documentation lists all of the commands. I don't have any plans for formal collaborations with people, but feel free to offer any suggestions you might have. The code is freely accessible to anyone.

Sedit wrote: "It would be a nice change of pace since my Neural Net is giving me massive headaches the past few days."

Don't give up. If you push yourself you can make greatness.
Sedit
7
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 5th Nov 2017 07:07
Wasn't thinking nothing formal just maybe a draw a sprite or two here or there or however it is you update this be it hard coded or sprites.

Give up??? Ohh noo I dont know the meaning of that. Even when I should lol. Na Im currently getting my feet wet back in C++ again. I am about to build a library for my evo sim just to defer some of the labor intensive function of the sight handler over to C++ in order to try to eek out a few more FPS and extend the reach of my Net by many more Neurons(esp if I can get the Nets Maths Functions to run on the GPU ). I just don't know if or how to use pointers in DBPro because I would need to pass the address of an array or data location to C++ because DBPro does not allow UDT to pass to a function nor Arrays. Im not sure how that effects library development but it would not be hard for me to compile C code into a DLL, Just a matter figuring it all out and putting it all together.

I have made Plugins when I was younger to make User defined buttons in Visual Basic. It was mainly about making the functions in C++ and compiling them to a DLL, Linking DLL to the Basic project and Declaring the function calls, data structures and Constant in Basic before use. I having Officially looked into it for Darkbasic but I assume the process to be the same.

I picked up DirectX SDK today because I have been tinkering with GLFW and SDL in C++ but it dawned on me that for the past few months I have essentially just been programming in DirectX9 so the transition should be relatively easy. I am finding DX to be running smoother then the other Libraries anyway with way less compatibility issues then I was having Esp with GLFW when I got pretty deep into building up myself a library for it and found I can't even run a lot of the code due to the fact my graphics card does not support OpenGL 3.0 .
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Nov 2017 22:17
Looks very good Mage.

It's good to see people doing useful stuff for DBPro.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 9th Nov 2017 01:20
Thanks. I was going to do this anyway, so I decided to do it in a way that helps others.

I am about half done the next update. The multi-line textbox was very time consuming to design. I also thought up a few more enhancements that will be included.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 15th Nov 2017 09:37 Edited at: 21st Nov 2017 10:34
Content Update 6
Multi-Line Text and Textboxes.


I have implemented multi-line text and textboxes. This was very convoluted and took a great deal of time, gladly it is done. ASCII character code 10 is the newline character. The font system will draw multi-line text and shadowed version. A multi-line label is added so text can be easily added to a panel. The multi-line textbox supports auto complete, and a full range of editing controls. Home/End, Arrow keys, Return Keys, Delete/Backspace are all included. Basically this took the most complicated portion of this project and added an extra dimension of complexity.


Drop Down Lists.


Drop down lists are like regular lists except they roll down and up when used. Basically its a widget that contains a regular list and manipulates it into behaving like a drop down list. All of the list functionality is built-in. Since this control can overlap other controls when it rolls out, it will override all of the other widget controls when opened so buttons underneath cannot be accidentally clicked. This was possible since the mouse controls were all managed from the start making control lockouts possible. Functions for locking out the mouse controls have also been added to the documentation, making it easier to build menus with overlapping windows and controls.


Referential Integrity and Lists.


From the beginning lists have had a major limitation that has been corrected. Before you would add text to the list and there was no way to handle situations where the list had two or more of the same text entries. You'd basically lose track of which entry truly was which. You also couldn't add empty strings. Now each entry has a hidden reference key. This is an optional feature, you can make them all 0 if you want. The reference key does not appear on screen. Instead you can use it to keep track of the text entries. For example an array of names has a unique array index for each name. When you put the names into one of these lists, you can make the reference key for each name be the array index. This way you can reliably link back to the correct records. Documentation is updated with functions that use this feature.


MFont - Bitmap Font Scramble Immunity.


The bitmap font system included as part of this project has been updated to no longer be affected by Dark Basic Professional bugs that reset Sprite U/V coordinates. Previously the characters were generated using sprites that linked to a font master image using sprite u/v adjustments. Now the bitmap font system will automatically generate separate images for each character from the font master image. Because of this there is roughly a 10 second processing period added to the launch of any program using this system. This can be reduced if the number of fonts being loaded is reduced. For the purposes of this project a larger than normal variety of 10 fonts is included and loaded.

This change will prevent random unrelated image/sprite loading from scrambling the bitmap font system. The extra delay when launching should not be significant. It's not a delay anyone would notice since it happens only at launch. I will also add that this delay could be reduced significantly if the fonts were stored with all of the characters in separate images rather than a big master font image, but I feel this would make it more difficult for people to create new fonts for the system since the tool for making the font images was not designed with this in mind.


Additional Enhancements:
MInit_Custom() was added so that this system can be initialized using a custom starting number for image/sprite indexes. The default is 1000.
Bug fixed that prevented deleting labels.
Bug fixed that would crash the program if a list was searched and result not found.
Some List related functions were updated to include the Reference Key feature. This will break existing code using earlier versions.


Upcoming Update.
Tentative bug fixes, if any are found. I just remembered when writing this that the debug menu wasn't updated to show data on the new widgets this update added. Might patch that.

Content update 6 has been uploaded and attached to the top post!
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Nov 2017 17:14 Edited at: 15th Nov 2017 17:19
Solid work Mage

Care for a challenge?

The dynamic border image.

User can supply static sized image components (corner piece, edge piece, etc) that will be applied to fit any size ui box element.

User should be able to specify individual sides or all sides (example apply to top edge only, apply left and right sides, apply all sides, etc)
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 15th Nov 2017 21:27
Are you talking about using an image to make a customized styled window instead of solid coloured windows?

Since the last update will copy character images out of a master font image, this capability could be re-purposed to also cut separate background window element images out of a master image. Then the 3 lines of code each widget has to draw the background and title bar could be overridden with a function call to draw a window with the images instead. Some sort of override for lists would need to be created so that they look okay embedded in file load and save dialogs.

This then leads to the issue of doing the same for buttons.
Many of the buttons are hard coded and would need to be converted into embedding MBasicButton a bare button widget instead. If this were done then converting that button to use the existing graphical image button instead would be fairly trivial.

So this could be done.
zero32
8
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 17th Nov 2017 08:12
i made a simple programm to test how the system will handle a shi*load of button controlls and i am impressed. i took a quick look at the source code and saw you didn't use sync rate at all but made some calculations to manage a solid framerate. i can almost feel the love that went into the making of this system. good work.
as evil minded as i am, i tested if overlapping buttons still work, even if i can't think of a good reason to position buttons like this in a normal programm/game.
if you overlap 2 buttons, both light up, but most of the time, only the button in the back will execute, probably because it gets called earlier.
so if you ever find yourself not knowing what to do next with the system, you could try adding a z value to every element.
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit

Attachments

Login to view attachments
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 18th Nov 2017 08:44 Edited at: 18th Nov 2017 09:03
zero32 wrote: "i made a simple programm to test how the system will handle a shi*load of button controlls and i am impressed. "

Thanks. That was update 5. I had a problem where the maximum number of controls needed to be set when the program started. I noticed that 1 and 2 dimensional arrays can be resized without losing the contents. This was built into the system in a way where it will up the maximum automatically when needed. So the problem is no longer anything that needs to be thought about again. You'd need to run out of RAM making controls you can make so many.

Zero32 wrote: "i took a quick look at the source code and saw you didn't use sync rate at all but made some calculations to manage a solid framerate. i can almost feel the love that went into the making of this system. good work."

You'd also like that the program is using far less CPU power than if I had used Sync Rate or VSync or Sleep. Instead of having free time between frames and burning it up between frames, it is returned to Windows. This saves battery, reduces heat, and lets the program work better when multi-tasking. This feature can be adjusted even turned off.

Zero32 wrote: "as evil minded as i am, i tested if overlapping buttons still work, even if i can't think of a good reason to position buttons like this in a normal programm/game.
if you overlap 2 buttons, both light up, but most of the time, only the button in the back will execute, probably because it gets called earlier.
so if you ever find yourself not knowing what to do next with the system, you could try adding a z value to every element."

I kind of already have implemented a method of handling overlapping buttons. Just not in the fully automatic sense you mention. MInput_MouseLock() and MInput_MouseUnLock() can be used to create menu systems that lock out the mouse controls for other menus you might have on the screen. The drop down list control makes use of this feature (when open). I had to implement this since the list would very likely overlap other controls. Scroll up a little, under the post for Update 6 there is an animation demonstrating this. Combined with Minput_IsMouseOver(x, y, pixelwidth, pixelheight) this is also the method for locking out mouse control for mouse controls not built into this system. Minput_IsMouseOver() will always return false if the mouse controls are locked so any menu section can use this to immediately skip handling any input. The built in controls do this already, but even non-standard menus you might design can use this. That's why it was included in the documentation. In a way its better than simply making it fully automatic since it looks ahead to see what you might need when actually designing a real program.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 20th Nov 2017 10:31 Edited at: 20th Nov 2017 10:31
Project Milestone


I seem to have reached where I originally wanted to be with this project. I realized that I could pour a huge amount of effort making very polished program pieces and get away with it because they were built in a way where they were extremely reusable in other programs. Then everything I made would inherit that high level of design.

Looking back at what I started with, my bitmap font system BFont it seems pretty basic by comparison. MFont is faster, far more capable, and doesn't have those annoyances the old system had. Then all these extra controls and widgets. What really got me to do this was lists. I'd make a menu and it would have a list, like files or quests or something else to load or edit. It would just be lines of text on the screen and eventually I'd run out of room at the bottom of the screen. Then making the text selectable by keyboard or mouse clicking was awful. The code would be really complicated and long and thus ugly. It would often be half made. Worse yet I'd have to redesign the menu over and over again between programs and menus. Not anymore. Then I went on to make a bunch of other stuff which always seemed to be a pain to create. The file load and save dialogs are really going to come in handy.

So this is a turning point for the project. I'm now going to reap the rewards of my work. This will also allow me to extensively test, patch and enhance things. So over the next little while you should see me releasing minor updates. There might be another major update over the horizon, I haven't really settled on any good ideas. There is one idea that I have been mulling over this entire time. Gamepad support is always a pain. I want a system that makes it easy to rebind controls, handle multiple controllers and input types, and a bunch of those other longstanding problems. There is also some other advanced things like managing objects/textures or recovering from loss of screen device which I didn't include because they would complicate things for people trying to use this system (they generally require you to build a program in a specific way). So down the road I might do that. For now though it will be minor updates.


Minor Update 6.1

This update includes a few fixes from issues that I mentioned previously and a few more that I encountered when attempting to integrate this modular code system into one of my games.

Enhancements:
Fixed a bug that would crash when creating button lists.
Debug window now shows widgets introduced in update 6.
Textbox and Multi-Line Textbox now can have their captions changed without needing to be remade.
Error in documentation index preventing Textbox documentation from being accessible is fixed.

Minor update 6.1 has been uploaded and attached to the top post!
Sedit
7
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 21st Nov 2017 04:01 Edited at: 21st Nov 2017 04:05
Im thankful for your inspiration Mage, I started working on my own GUI interface Library a few hours ago and am pleased with how its turning out considering the little effort I have placed in it so far I think its going to come together nicely. Basically I am going to have a Makeshift WINGUI type Library Module that I can add to any project I am working on in order to make myself Menus, Windows Buttons ETC....



Its running kind of slow at the moment so I am just going to have to change the means through which I render the windows is all making a general sprite of Maximum length then Subsecting it down to size for starters. That would give an insane speed boost since I am currently rendering them line by line basically just as a prototype test for the other functionality of the windows such as assigning Function Pointers to specific buttons and things of that nature. Everything seems to be working just fine on it other then the fact that I don't have the Priority Variable of the windows Currently setup but that won't be very hard at all I just have not done it because the project is only a couple hours old at the moment.


Tomorrow or maybe later tonight I am going to fix Priority so they draw in the correct order and windows don't start dragging just because I mouse clicked over them while dragging a different window and things of that nature. Im also going to put Menus on and setup a class structure for everything, I know DBPro does not do OOP but similar things can be accomplished using Function pointers and Type Defs so that's not a problem.

What do you think? Almost looks like real windows don't they. Just gotta get the motion a little more fluid and It will be on point.

Attachments

Login to view attachments
Sedit
7
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 21st Nov 2017 04:42
Almost embarrassed about that last video, I went back and did a quick 15 minute alteration of my code and the way the windows render and my FPS went from around 5-7 frames per second to around 190FPS or so . I had to frame limit the damn thing just so my mouse stays on the window while trying to drag it.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 21st Nov 2017 10:23 Edited at: 21st Nov 2017 10:28
First I think it's great you're taking inspiration and good luck with your project.

A few things:

1. Why re-invent the wheel? The entire point of my modular code project is to solve these issues for people. Why not avail yourself of the benefits offered here?

2. My modular code project is designed for use in PC video games. It's deliberately limited to what I feel I would need there. So all of the trying to emulate the windows gui, you need to ask yourself do you really need that? Is it worth the trouble? Is it simple for other people to use? When was the last time you saw a video game with overlapping/movable windows? There's a case to be made, but is it a strong one?

3. One of the biggest problems with making games in DBP is that the default text system uses system fonts which the gamer needs to have installed on the computer otherwise the text doesn't appear correctly. Using system fonts is really impractical. The default system also lacks many features like shadows and transparency. This is why my project uses a bitmap font system called MFont as it's foundation. The text appears the same on every computer, and has advanced stuff like shadows and transparency. It can even create images of the text that you can simply paste to screen since in video games performance and efficiency are supreme. So watch out with your system that you are not overlooking this core problem as changing things later could be impractical.

4. Depending on what you mean by subsecting sprites, you might find this creates unbearable lag spikes when the processing happens. If you are adjusting sprite u/v coordinates be aware that they will be reset to default any time anywhere in the program you create or load a sprite or an image. So this might not be practical in the real world.

5. Don't use the built in 2D drawing commands. Use the Advanced 2D plugin. Better in every way.

6. The hardest part is finishing the job. So many people dream big, too big and never finish. You need to scale your project down to something you can actually finish.


Now I want to be a bit frank here since I think it will help you. You were making some sort of neural ai project, and your interests appear to have moved on from that. You are now here talking about redoing something that's already been done, but seemingly in a much larger scope. I do not get the impression you will be able to finish this project. You might not be setting yourself up for success.
Sedit
7
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 21st Nov 2017 15:12
Quote: "1. Why re-invent the wheel? The entire point of my modular code project is to solve these issues for people. Why not avail yourself of the benefits offered here?
2. My modular code project is designed for use in PC video games. It's deliberately limited to what I feel I would need there. So all of the trying to emulate the windows gui, you need to ask yourself do you really need that? Is it worth the trouble? Is it simple for other people to use? When was the last time you saw a video game with overlapping/movable windows? There's a case to be made, but is it a strong one? "


Two fold, Mainly, because I'm still learning Darkbasic Lang and am finding little Demo programs such as this are helping me learn more which I can carry over to my other projects to speed development and improve performance in various areas. For instance until right before starting this I knew almost nothing of the Sprite commands and had yet to use them up till now. It even triggered me to rethink the AI I was working on a convert its core to 2D so that I can achieve results I was looking for because 3D is just to hard on the system and because of that I may be able to jump from 50 creatures to running thousands.

All that being said I feel that people want familiarity when they are playing a game or working with a program and the more you can make it feel like windows the more comfortable people will be when using your program.

Quote: "
3. One of the biggest problems with making games in DBP is that the default text system uses system fonts which the gamer needs to have installed on the computer otherwise the text doesn't appear correctly. Using system fonts is really impractical. The default system also lacks many features like shadows and transparency. This is why my project uses a bitmap font system called MFont as it's foundation. The text appears the same on every computer, and has advanced stuff like shadows and transparency. It can even create images of the text that you can simply paste to screen since in video games performance and efficiency are supreme. So watch out with your system that you are not overlooking this core problem as changing things later could be impractical. "

Thank you for reminding me of this, That could indeed become and issue somewhere down the line I may need to take into consideration. I could envision a basic font system based on the DATA command but not really sure how I would handle it until I got to that point.


Quote: "
4. Depending on what you mean by subjecting sprites, you might find this creates unbearable lag spikes when the processing happens. If you are adjusting sprite u/v coordinates be aware that they will be reset to default any time anywhere in the program you create or load a sprite or an image. So this might not be practical in the real world......
5. Don't use the built in 2D drawing commands. Use the Advanced 2D plugin. Better in every way. "


Well when I was first musing about it and wrote that I had plans on loading the sprite full side and then just cutting it down to the size of the window border at that area but when I recoded it I instead took a different approch and just stretched the sprite on its X axis and then rotated it 90 degrees for the horizontal lines.
Each Sprite I am using is only 1x5 pixels. I just stretch it to size. I don't for see any lag to deal with because I don't plan on having anymore the two to three windows at a time and this as running at 190 FPS. Think most programs I will only need a windows and maybe a message box pop up here and there through out the program but I don't really envision anything larger then that at the moment.

Good to know about advance 2D, I will have to look into the commands as I don't know much about it at the moment. Is there any place I can get a list of the commands it contains? I believe I have it but like a couple other Plugins I have I currently don't know much about it.

Quote: "
6. The hardest part is finishing the job. So many people dream big, too big and never finish. You need to scale your project down to something you can actually finish. "


Fair enough, since I know from first hand experience exactly what you mean, however what you see there is only a couple hours of work(Including learning all the 2D sprite commands) and I already know the ground work so it really won't take much time at all I could honestly have a fully functional(to my needs anyway) GUI done in under a week if dedicated to it. Your work inspired me to start working on such a system since I have always built up my libraries of work in a similar way to make code swappable kind of made me reevaluate the way I am going to use DB because I did not have any plans on sticking with it and was just going to use it as a stepping stone while I got back into programming but the more I toy with it the more I see that I may just use C++ as my supplement Lang only to make Libraries for darkbasic. IDK Guess I sort of expected a better reception of it, I for one thought it was pretty cool to have it working as nicely as I did with close to the look and feel that I was going for.

I started programing like this back when I was a kid using TURBO C++ and BORLANDS C++. Basically the same Philosophy you are promoting here making various libraries that can be snapped together in different ways for different effect. Mostly various graphical effects back then since it was all about writing to the hardware back then and I am not sure todays programmers are ever going to have the joy of trying to memory Blit their Backbuffer to the screen only to have made a typo somewhere and you just Blitz a 320x200 area to god knows where in the memory. Or how great it was trying to use 32bit protected mode for higher resolution in which you had to Blit 4 of those said block just so you could have 600x400 resolution with 256 color . lol.

As such this will never be fully finished, Instead its a library that will grow as my work in Darkbasic grows and various new tools are needed. The current incarnation is about to have your basics that I will be able to use in any project I might need such as buttons

I started making it because that game me and my kids made a couple days ago was lacking Help Menus and I wanted to add a user interface to it and this started to grow out of that frame work. At first just meant to be a simple window that popped up displayed the commands and then was gone at the click of a button I got bored and decided to make it look as realistic as I could.


As far as the AI, It hit a wall, The performance issues are preventing me from taking it to a level that I desire to with out making exponentially large compromises at every turn which are starting to hinder performance on multiple different levels. That's why I took a brake and made that Battle Ballz Game with the kids

I have started converting the entire AI system over to 2 Dimensions because I am capable of performing many many more Calculations per second when I am not attempting to do any sort of complex Object movement or collision detection. Its a lot less CPU intensive to just check a grid to see if there is already a dot there then to detect 3D collision normals,
Its currently looking somewhere along the lines of 1000-5000 creatures that will be able to be fully rendered per frame as opposed to only 20-50 on my computer at the moment.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 4th Dec 2017 07:48
Minor Update 6.2

This update includes bugfix to right click handling. Specifically the activate when released functionality now works correctly. The demo examples and all of the controls included don't use this feature yet it was included. So it took me a while to discover it was never fully implemented. Now that I'm writing this I realize I never did middle mouse button... I'll look into that. Might be useful to activate when released that button too.

Minor update 6.2 has been uploaded and attached to the top post!
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 10th Feb 2018 00:11 Edited at: 10th Feb 2018 00:21
Minor Update 6.3

This update includes support for middle mouse button. Button presses like other mouse buttons will activate on release.
Auto-Complete has been tweaked to only suggest after 4 characters. It was getting hard to type a lot of smaller words with so many bad suggestions triggering. 5 character minimum seems to be a nice balance.
Font system is no longer hard coded to load 10 fonts. Instead the system will auto detect fonts numbered 0 to 255 that are placed in the fonts folder along side the compiled executable. This allows for excess fonts to simply be removed from the folder immediately speeding up initial program launch. Also additional fonts can be easily added.

Minor update 6.3 has been uploaded and attached to the top post!
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 3rd Mar 2018 04:53
Sweet stuff man, very much appreciated, saves time for a lot of folks. Nice one
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 4th Mar 2018 20:27 Edited at: 4th Mar 2018 20:52
James H wrote: "Sweet stuff man, very much appreciated, saves time for a lot of folks. Nice one "

Thanks, feedback is huge motivation.

Since this thread got bumped I'll squeeze in a small but important update.
Basically the scope of this was purely from a video game perspective, which meant the file load/save dialogs only needed limited directory traversal. Using this to make a tool is different so they have been enhanced for that.

Minor Update 6.4



This update enhances file load/save dialogs with drive support and full directory traversal. Previously it was limited to within the initial path given. This is implemented as allowDirChange = 2. See documentation for further details.
Bug fixes to file load/save dialogs ranging from cosmetic to apocalyptic. This is an essential update for this reason.

Minor update 6.4 has been uploaded and attached to the top post!
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 5th Mar 2018 16:37
Nice work

This kind of core system functionality is always a pain to set up, so it is nice to have ready made options
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 9th Mar 2018 11:16
Nice, thanks for the update. My illness kicked in so I haven't done anything recently but I've had a fairly good look through the previous version of this, was actually quite enjoyable Warmed me up for what is to come lol.

First thing I did was use just 1 font for my purposes which cut load time greatly. Darn image to memblock is slooow but no matter I only want the 1 font anyway.
I also noticed the read back variable for the font dimensions from text file are floats but the file is integers, then I noticed the next function to generate an image casts the float back to integer. I thought the floats must relate to something so I would ignore for now, but then I did a quick google search and found a system font tool that produces an xml and png. First thing caught my eye was all the xml character dimensions where floats.

So this leads me to ask for a bit more info relating to how to produce a good looking font - they only seem to be readable when the source image is large and the output size is also fairly large. Doing quick "replace all" after removing descriptive characters left me with floats and colons so all I had to do was add the unique identifier(ie 32 on-wards at start of each line), but then I was left facing whether to round up or down the float values, just remove the decimals as they are or leave as is - or I could watch the output as they are created - the bit you remmed out - and tweak them manually based on how they look in action. I was hoping to use smaller fonts so went for 512^2 and 256^2 both leaving floats and removing them but results looked, well not good! So rather than me waste more time on this specific issue I thought to myself I can get on with other stuff and it's more than likely Mage has this process way more refined so ask him...so here I am asking How have you been doing them?

Besides this, I haven't actually injected this into my own code, 6k lines compile added to what is now 3.5k of my own code is a lot on compile time, I figured I would inject it as a simple test then rem out the basics and remove the dba for future compiles while reverting to the regular file dialogue, then when I'm nearer to the end of it all I can just add/rem it all back in. First though I have to look at the way it updates. This is because you use sync sleep which I already use in a very cheap and nasty way! That said it looks straight forward, might even be just a few lines...still waking up here!

Side note - this might be nice as a plugin - look at how the advance lighting plugin speeds up compile times from absolutely forever to next to nothing! Have you considered this? Maybe I have spoken out of turn there - I don't know what effort that this would take as I know nothing on creating plugins. I have removed a few hundred lines that the dialogue doesn't need but am at 4875 lines, there will hopefully be lots more I can remove I haven't spent all that much time on this part as its slightly complicated process and it is modular so there is only so far I can go with removal. Am currently only using the load dialogue as my save routine is taken care of by naming what becomes an export folder in a specific directory within the tools main window.

There is another thread relating to this command (sync sleep)which I don't really want to get involved in but I will say this, to my knowledge it is a flag state, once upon a time you used to be able to use 0 or 1 for flag state or add any value to it when it is in main loop and it would "hand back control to windows for x amount of time per cycle" which the help files used to reflect hence that old code being there that no longer works. The main issue with this was the way I noticed some folks monitor performance using task manager. This is a bad idea as task manager takes as much control with immediate effect as it can from running apps and windows can take a while to hand it back once task manager has ended. That is the cheap and nasty part of what I say is a "trick". Basically I use "silent" task manager and sync sleep 1 together to get cpu usage right down for the obvious purpose of hardware wear and tear and of course electric consumption as those two things are vital to me as I live on benefits. This is not ideal I know - it is not the right way to do things, but it is quick and gets used a lot by me when just playing around with code. It is also brilliant for spotting when newton physics is beginning to struggle because I can see the cpu spikes when the plugin has too many wheels to process - I am only ever using the cpu usage command to read back usage, task manager is only ever minimized/hidden to tray when it is used. It does drag on fps performance greatly - as does using flag state 1 on it's own - but I have a button to regain control of cpu on the fly...I just have to wait a few minutes for windows to make that happen.

Instead of task manager you can just plot a graph using the enhancements dll from fpsc free, in order to get cpu usage(not app but overall usage). Running this before opening task manager shows the massive effect task manager has on performance when opened alongside an app.
Sync sleep 0 = 100%
Sync sleep 0 + task manager = 50%
Sync sleep 1 = 50%
Sync sleep 1 + task manager = <10%
Flipping between states 0 and 1 without task manager involved and the jump between 100% and 50% is almost immediate
Do the same with task manager open and the jump between <10% and 50% is almost immediate - close task manager at any point and you may have to wait minutes and minutes before you see usage return to either 50% or 100%. This must be because windows still has control which I state based on what the help files used to say when it said something to the effect of values above 0 would hand back control to the OS. I think this may be why people saw different behaviour rather than it being down to different OS's. Then again never say never, however I saw the same behaviour on win10 when I used to have that installed. One thing to note is that with the above tests - if you have task manager open with your app and then close both, re running the app doesn't mean you will instantly get usage back from windows, nope instead windows remembers it somehow and you still have to wait for usage to be handed back, so if you test this, please be aware that at start of each test you are 100% sure you have been handed back any usage that windows controlled by simply waiting a while if you haven't yet been given it back.

Gawd I hope that made some sense.

Here is the basic graph code(needs a2line plugin as well as enhancements dll). Run it you should see it "top line" ie 100% usage, while it is running open task manager, watch it change, close task manager and wait several minutes and it should go back to 100%. Repeat with sync sleep 1 instead. You should see what I am trying to say. Add a line of code to switch state flags on the fly and again repeat both processes and watch for immediate changes versus waiting minutes for windows to hand back control...anyway, the code:

Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 10th Mar 2018 19:51 Edited at: 10th Mar 2018 20:21
Quote: "Nice, thanks for the update. My illness kicked in so I haven't done anything recently but I've had a fairly good look through the previous version of this, was actually quite enjoyable Warmed me up for what is to come lol. "

I hope you get well soon.

Quote: "First thing I did was use just 1 font for my purposes which cut load time greatly. Darn image to memblock is slooow but no matter I only want the 1 font anyway."

Yes I suggest this. It's not typical to load 10 fonts for any game or app. However even if you did on a big project, an extra few seconds delay launching the app is the best kind of delay. Once the app is up, there's no longer a problem. This design is done because the faster design was affected by DBP bugs. If you change the U/V coords of a sprite (like font letters) when you load an image/sprite anywhere else in the program, all u/v data for everything is reset. This caused the text to scramble.

Quote: "I also noticed the read back variable for the font dimensions from text file are floats but the file is integers, then I noticed the next function to generate an image casts the float back to integer. I thought the floats must relate to something so I would ignore for now, "

I could explain a more specific example. However there are many things to consider. Things like Kerning, which adjusts the letter spacing, scaling of the text, and positioning. I have had issues avoiding having the letters drift on long text strings, and centering text. Rounding errors can creep into text and accumulate if unchecked. Things work really well now but there is room for polish there. Also keep in mind I have attempted to keep performance fast.

Quote: "but then I did a quick google search and found a system font tool that produces an xml and png. First thing caught my eye was all the xml character dimensions where floats."

The top post of this thread I link to a font creation tool that is compatible with this system. Quick and easy.

Quote: "So this leads me to ask for a bit more info relating to how to produce a good looking font - they only seem to be readable when the source image is large and the output size is also fairly large."

You'll need to pick a good font. Something with clear lettering. Somethings like cursive writing are hard to see no matter what you do. Keep the source image big. You'll get more clarity. The font scaling is based on simply scaling a sprite. So it's possible there's an enhancement available in some form.

Quote: "Doing quick "replace all" after removing descriptive characters left me with floats and colons so all I had to do was add the unique identifier(ie 32 on-wards at start of each line), but then I was left facing whether to round up or down the float values, just remove the decimals as they are or leave as is - or I could watch the output as they are created - the bit you remmed out - and tweak them manually based on how they look in action. I was hoping to use smaller fonts so went for 512^2 and 256^2 both leaving floats and removing them but results looked, well not good! So rather than me waste more time on this specific issue I thought to myself I can get on with other stuff and it's more than likely Mage has this process way more refined so ask him...so here I am asking How have you been doing them?"

You might need those floats as other aspects of the system you aren't looking at might rely on them. Also be aware if you mess with the line/letter spacing you will cause the textbox to stop registering mouseclicks that move the text cursor properly. You'll click on a letter and the cursor will move to the wrong spot. So changing letter spacing other than changing the font's kerning value needs to be extensive. You'll need to make many changes. The kerning value can be changed and the system automatically accommodates this. This value is necessary as some fonts appear to spaced out or crowded and need adjustment. You you might be unravelling a sweater there.

Quote: "Besides this, I haven't actually injected this into my own code, 6k lines compile added to what is now 3.5k of my own code is a lot on compile time, I figured I would inject it as a simple test then rem out the basics and remove the dba for future compiles while reverting to the regular file dialogue, then when I'm nearer to the end of it all I can just add/rem it all back in. First though I have to look at the way it updates. This is because you use sync sleep which I already use in a very cheap and nasty way! That said it looks straight forward, might even be just a few lines...still waking up here!"

There's a bunch of functions you will need but most of them you don't need to keep. MSYNC syncs the screen, handles the frame limiter, and also manages the camera mask. All of these things have functions to enable/disable them. You don't even need to use MSYNC. So it's all up to you.

You lost me after that. You might want to bring up the Sync Sleep stuff in the other thread.
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 10th Mar 2018 22:36
Thanks. Much better tool, maybe I should pay more attention to what I'm doing...results are miles better now. You already stated several things I asked, sorry about that

Yeah forget the sync sleep stuff, wrong place, I shouldn't have posted sorry.
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 7th Apr 2018 09:11
Just thought I could deliver some upbeat news to cap the interesting week we had

Minor Update 6.5
Inline Color Codes For Bitmap Text







This update adds the ability to have multi colored words in text, using hex color codes. We're no longer stuck with boring single hued lines.
Text formatting with this combined with multi-line and cropped run-on text isn't perfect and might need a slight tweak in a future update. We could fit a few more characters per line ideally.

Minor update 6.5 has been uploaded and attached to the top post!
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 8th Apr 2018 22:37
Very nice, inline styling is important
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 9th Apr 2018 07:51
Ortu wrote: "Very nice, inline styling is important"

Thanks! Such a basic thing that DBP and plugins don't support. This might be the most advanced bitmap font system DBP ever got.

Minor Update 6.5.1

Fixed bug where color code at begining of text was ignored.
Fixed bug where confined/cropped text containing color codes was cropped too short.
Fixed bug where multi-lined text didn't render color codes correctly. Variety of issues.

Minor update 6.5.1 has been uploaded and attached to the top post!
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 6th Jul 2018 06:07
Literally days from having thread time locked. Slipping in an update.
So it seems that some stuff slipped through the cracks even though every feature was tested and demos written.

Also I will mention after using this for months, this has been very helpful. Text boxes that work really well, buttons that handle the mouse properly, lists that automatically do everything. I used to have to repeat functionality all over the place and I'd get a bit lazy. Some apps would work a little better than others, some lists and buttons would work better than others. Now it's just 2 or 3 commands and everything is high grade, automatic, and consistent. Should have done this back in 2002. Without a doubt the most useful thing I have ever done.

Minor Update 6.5.2

Fixed some errors in the help documentation.
Fixed bug causing shadowed text to not render correctly alongside differently sized text.
Fixed bug where text converted to image was being cutoff at the end slightly.
Fixed bug that made two button dialogs not delete correctly, potentially crashing the program.
Fixed bug where inline color codes not terminated within shadowed text persisted overriding the main text color setting.
Expanded support for removing items from lists and drop down lists. Removing items was previously undocumented. (Breaks compatibility, undocumented command renamed)

Minor update 6.5.2 has been uploaded and attached to the top post!
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 4th Oct 2018 19:46
I didn't realize reopening this would bump it to the top. I am planning to do an update in a few days.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 6th Oct 2018 04:05 Edited at: 6th Oct 2018 04:05
This is the one year milestone for this project. Time flies when you are having fun.
Over the last year using this has given me massive quality of life improvement when making apps. Being able to rapidly add consistent high quality UI controls is a real game changer. I don't think there will be much more to add for a while. I am still looking at asset recovery (when game is minimized/restored) though this is hard because it would require people to program their apps in specific ways which is not realistic for a codebase like this. I am also looking at doing some sort of controller interface, which would make it easier to use and remap controller input in a simple manner. These are just ideas at this point.

Right now my main focus drawing my attention is an effort to convert DBO files to and from preferred 3D editor. This has long been a pain and no matter what conventional method I use there is missing functionality. So I have decided to just directly solve the problem. Needless to say this is really complicated and is taking a lot of my time. When this is done, I'll be back to game development and then back to finding general purpose problems to solve.

This update adds support for text links which operate much like buttons. So the link is fully managed like any other control. They also support left/right/center text alignment and shadow text.

Minor Update 6.5.4
Text Links




Fixed some errors in the help documentation.
Added some additional sample fonts.
Added support for text links. They operate similar to buttons.

Minor update 6.5.4 has been uploaded and attached to the top post!
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 20th Sep 2022 21:11 Edited at: 20th Sep 2022 21:18
Hello! We're still in business.
In fact, if you see the top post I have been regularly making updates over the years!

This is an ongoing publicly available code base I have been maintaining, which adds basic UI functionality. The core of which is possibly the most advanced Bitmap font system developed for Dark Basic Professional.

Minor Update 6.7.2
Tree Lists

These operate like regular lists but include an expand and collapse feature that allows a simple tree list presentation.




Inline Text Icons
The Bitmap font system already allows inline color codes in curly brackets {AARRGGBB}, this update expands this to include a {XX} code for inserting icons into text instead. All values in hex format.



Fixed some errors in the help documentation.
Fixed some controls that could cause a crash.
Added setCaption to Progressbar Dialogs.
Added initialization loading screen. This might need to be revised as it's not as functional as I want it to be.

Minor update 6.7.2 has been uploaded and attached to the top post!

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!
Bored of the Rings
User Banned
Posted: 21st Sep 2022 10:24
really smart this Mage, will test out the latest version and report any issues.
Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 21st Sep 2022 11:50 Edited at: 21st Sep 2022 12:09
@Mage - had to manually add the include files. Also, there is missing REM statement, 2nd line in the "modulartemplate.dba", causing compile issue. This is for the demobutton program.

[update-same issue with backgroundanimation.dba]
Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 21st Sep 2022 16:09
Thanks for checking but when I unpack the file and check I find that this error is not present:



I hope this works out for you or at least gives you some ideas. Making half decent programs has been supremely easier/quicker with this project as I don't have to reinvent buttons and controls, and have them be inconsistent and lacking functionality. I can do a higher level of quality because it's entirely reusable. Plus I can just update the codebase and drop it into programs that use it. Just a tremendous advantage. I don't have to care if the user has fonts installed. I can have the system generate an image of the text that I can paste to screen whenever just so that I don't lose any performance from overhead. It will even do it automatically if fast text is enabled.

I'll mention though that DBP sprite scaling appears to be nearest neighbor, no apparent way to improve that. So the Font does not always look the best when small. Sometimes you need to be picky about which font you use at those scales. I hope someone reads this and has a solution. There is a tool linked in the top post that someone made that can make custom fonts for this system.


Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!

Login to post a reply

Server time is: 2024-11-17 22:34:29
Your offset time is: 2024-11-17 22:34:29