93 Commits

Author SHA1 Message Date
IntegratedQuantum
c2ef9aba62 Remove the root . . . . . . . . . . import, replacing it with @import("main")
To fully solve the ZLS issues I had to also add the import to the other executables.
2025-03-27 21:16:35 +01:00
IntegratedQuantum
39fe3bd1a7 Replace tail call recursion in gui.zig with a standard while loop.
This brings us one tiny step closer to overlapping with the set of supported features of the x86 backend.
2025-03-11 21:59:05 +01:00
IntegratedQuantum
09fc516828 Move all the allocators to a separate file. They can now be imported with main.heap (analogous to std.heap)
I also removed the unused BufferFallbackAllocator which was from a time where I was still experimenting with different allocators.
2025-03-09 16:26:41 +01:00
IntegratedQuantum
bc02bb0587
Use (an adapted version) of zig fmt to format the source code. (#1140)
* Format all the files

* Fix compilation error.

* The install scripts now patch render.zig from the zig standard library.

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update the formatter, it doesn't need to run on .zig files anymore.

* Update ci.yml

* Update ci.yml

* Add a mistake to check if it works

* IT WORKS!
2025-03-02 16:36:58 +01:00
IntegratedQuantum
868b4aade3 Keep crafting more when holding left click in inventory crafting.
fixes #1051
2025-03-01 15:23:05 +01:00
IntegratedQuantum
7145aca964 Support simple modifiers (currently they can only change tool stats one time) 2025-02-25 21:26:17 +01:00
IntegratedQuantum
3a8d4d32ab Rework how gui callbacks check whether the player is in the game or not.
It now behaves correctly on key collisions where one of them changes the grab state.

fixes #1001
2025-02-02 18:14:11 +01:00
OneAvargeCoder193
1de5efbf6e
hopefully save the hand and also when the player leaves or server closes (#943)
* hopefully save the hand and also when the player leaves or server closes

* fixes

* change it to check the user id

* fix

* check pointers

* fix compilation error

* fix other bugs

* put player id in source

* fix error

* remove one line of code

* fix serialization

* revert < 22 to < 14

* change

* fix error where inventory not saved on alt f4

* change connected to a regular bool

* remove isConnected function
2025-01-26 21:30:23 +01:00
IntegratedQuantum
36c38dca2d Show an error prompt every time there is an error message added to the log.
This should make it easier to find and fix problems in the assets.

fixes #911
2025-01-12 16:41:32 +01:00
IntegratedQuantum
1b1f61cae9 Change some warning messages to error messages.
Errors are things that come from actual problems, like incorrect parametrizations.
Warnings are things that hint at potential problems, but could also occur during regular runtime, like for example server lag.

progress towards #911
2025-01-12 15:54:53 +01:00
IntegratedQuantum
de2e4aedb4 Rename ZonElement.free to deinit to follow zig convention. 2025-01-01 20:27:31 +01:00
IntegratedQuantum
de90b4ede3 Introduce a ConcurrentQueue to reduce the number of raw mutexes used throughout the code to simplify the code reduce the chance of (multithreaded) deadlocks.
For now it's just a queue with a mutex.

this might help with #863 and #864 in the future.
2024-12-30 00:59:45 +01:00
IntegratedQuantum
c495e8406c Fix some problems with window closing and the delete world confirmation window.
Seems relevant for #809
2024-12-05 22:05:08 +01:00
IntegratedQuantum
5f7ccd0504 Load the settings and gui_layout files from a global directory.
For linux and mac I just use "~/.cubyz"
For windows there seems to be no consensus on where game data should be located.
Out of the commonly used locations, "~/Saved Games/Cubyz" seemed the most sane option to me.

fixes #457
2024-12-01 11:48:31 +01:00
IntegratedQuantum
8f15690b85 Call the onCloseFn when toggling a window.
fixes #749
2024-11-15 22:03:23 +01:00
IntegratedQuantum
d9da715e6b Fix use after free of ItemSlots.
fixes #768 and some rarer related issues.
2024-11-13 21:17:45 +01:00
IntegratedQuantum
2b7bde161e Introduce an InventorySource type to describe where an inventory comes from.
In future e.g. for a chest this could contain the chest location, so the server knows which chest to open.
more progress on #643
2024-10-28 20:21:42 +01:00
IntegratedQuantum
79d7393c4e Serialize/Deserialize inventory commands and send them to the server.
More progress towards #643

I had to temporarily disable inventory crafting to make this work for now.
2024-10-26 16:42:00 +02:00
IntegratedQuantum
b710ccad07 Squeeze all inventory operations through a simple structure that allows undoing operations.
more progress towards #643
This is the client-side prediction part of the client-server architecture.
2024-10-18 22:17:47 +02:00
IntegratedQuantum
051387e66b Fix item swapping on left click, previously they didn't swap because the inventory was trying to do a distribute operation instead of a depositOrSwap operation. 2024-10-16 20:29:55 +02:00
Zachary Hall
e6fa7498c6
Game controller support (#717)
* Refactor getting X positions of buttons in preparation for not moving the window when clicking the buttons

* Initial support for controllers

* Basic controller support

* Allow runtime download of gamecontrollerdb.txt

* Add new gamepad cursor asset, and use it.

* Various improvements
Allow saving and configuring gamepad mappings
Add gamepad sensitivity, for camera only
Adjust multipliers in usage of gamepad axes
Prompt for downloading controller mappings, and allow configuration

* Refactor startup window handling so that controller settings does not duplicate code, or have to detect if startup has finished

* Clamp cursor position to window size when changing via gamepad

* Add deadzone

* Implement changes requested

* Follow more suggestions

* Use atomics

* Use orelse for oldState in Gamepads.update

* Implement requested changes

* Fix accidental removal of whitespace on two empty lines

* Fix incorrect formatting on blank line due to Vim expanding tabs to spaces

* Fix build errors.

* Change unusual orelse usage with better if expression

* Add resettable keys

* Revert "Add resettable keys"

This reverts commit 902f032ec834161dcaac97cbe596788e0110e870.

* Update controller support

* Fix things I forgot about

* Fix more things

* Implement most requested changes and change button text to be more clear

* Update controller support

* Hopefully fix format without breaking it.

* Refactor getting X positions of buttons in preparation for not moving the window when clicking the buttons

* Initial support for controllers

* Basic controller support

* Allow runtime download of gamecontrollerdb.txt

* Add new gamepad cursor asset, and use it.

* Various improvements
Allow saving and configuring gamepad mappings
Add gamepad sensitivity, for camera only
Adjust multipliers in usage of gamepad axes
Prompt for downloading controller mappings, and allow configuration

* Refactor startup window handling so that controller settings does not duplicate code, or have to detect if startup has finished

* Clamp cursor position to window size when changing via gamepad

* Add deadzone

* Implement changes requested

* Follow more suggestions

* Use atomics

* Use orelse for oldState in Gamepads.update

* Implement requested changes

* Fix build errors.

* Change unusual orelse usage with better if expression

* Add resettable keys

* Revert "Add resettable keys"

This reverts commit 902f032ec834161dcaac97cbe596788e0110e870.

* Update controller support

* Fix things I forgot about

* Fix more things

* Implement most requested changes and change button text to be more clear

* Update controller support

* Hopefully fix format without breaking it.

* Implement suggestions

* Update controller mapping downloading to be more automatic

* Fix parameter in Window.Gamepad.ControllerMappingDownloadTask.isStillNeeded

* Revert order of window opening and opening next startup window in openStartupWindow

* Only download controller mappings the first moment a controller is plugged in

* Open controller mapping download UI when actually downloading mappings, or at startup if they have started before GUI initialization but haven't finished yet.

* Don't unnecessarily try to download controller mappings at init when it will be done once the first update happens anyways.

* Implement requested changes

* Remove debugging log output

* Implement changes to download_controller_mappings.zig
2024-10-14 17:31:59 +02:00
IntegratedQuantum
7901c721c3 Unlock the gui command queue mutex while calling window.open/close functions
This allows opening a window from inside the close function.

closes #736
2024-10-10 17:51:24 +02:00
IntegratedQuantum
3a4a695e3d Move all inventory operations that change the inventory into the Inventory struct.
Another important preparation step for #643

It does break a few things regarding inventory ui/ux, but those can be fixed over time.
2024-10-06 14:28:31 +02:00
IntegratedQuantum
b4f3dfbeca Replace json with zon in the entire game and autoamtically convert all json files when an old version is detected.
progress on #733
2024-09-29 16:28:16 +02:00
IntegratedQuantum
7f7dcd190a Refactor: Shorten the player inventory name.
It didn't particularly help anyways. In the future syncing should be done automatically instead of manually anyways.
2024-09-26 19:33:19 +02:00
IntegratedQuantum
72207c973e Refactor: Use decl literals, a recent addition to Zig. 2024-09-14 14:54:49 +02:00
IntegratedQuantum
330187b9ae Update zig version 2024-09-14 13:42:25 +02:00
ITR
df76d2da1b Added ctrl+a to select all text in a text-box 2024-09-07 22:27:19 +02:00
IntegratedQuantum
412d5b93b8 Improve world selection and creation interfaces.
fixes #577
fixes #576
fixes #575
2024-07-20 16:32:09 +02:00
IntegratedQuantum
289e3c61f1 Add VSCode section headers to make navigating large files easier. 2024-07-14 11:31:57 +02:00
IntegratedQuantum
337e014d88 Store settings and gui layout whenever it gets changed.
fixes #469
2024-07-04 10:24:57 +02:00
IntegratedQuantum
2e06b9d4af Add a button to hide the GUI (F1)
fixes #470
2024-07-02 22:18:05 +02:00
IntegratedQuantum
669ab890cc Title bars can now be revealed by pressing a button in the pause menu.
This removes the ugly triangle from the top left of all windows and makes it harder to accidentally move around windows.

fixes #536
2024-06-30 11:00:25 +02:00
IntegratedQuantum
d99c9ede01 Don't open windows when typing into a text field.
fixes #392
2024-05-26 14:39:35 +02:00
IntegratedQuantum
6da2971528 Refactor: Move the Window struct out of main.zig into its own file. 2024-04-23 16:30:30 +02:00
IntegratedQuantum
82be61ed6d Implement mutex assertions only in debug mode.
This avoids side effects in release fixing #317
2024-04-16 22:16:19 +02:00
IntegratedQuantum
44a786165d Properly handle closing the game menu.
Fixes #37
Fixes #248
Fixes #283
2024-03-25 14:17:37 +01:00
IntegratedQuantum
b6cffba122 Some small UI improvements
Fixes #245
Fixes #262
Fixes #284
Fixes #285
2024-03-24 20:00:21 +01:00
IntegratedQuantum
899083569d Remove redundant window ids. They were asserted to be equal to the file name, now they are initialized to the file name, removing the need for setting it manually.
This makes adding new windows simpler, also affects #273.
2024-03-19 22:17:46 +01:00
IntegratedQuantum
d08096057f Improve the StackAllocator so it allows all kinds of allocation patterns.
This allows using the StackAllocator for more data structures and library functions.
Fixes #268
Fixes #95 (at least to the point where I can't do anything about it)
2024-02-08 18:01:43 +01:00
IntegratedQuantum
74c896c969 Handle errors locally instead of letting them bubble up into the main functions. 2024-01-31 22:42:20 +01:00
IntegratedQuantum
2c33f3779d Switch to a self-made list data structure that doesn't return OutOfMemory errors. 2024-01-30 16:34:40 +01:00
IntegratedQuantum
de004841b7 Handle OutOfMemory errors centrally for the globalAllocator and derivatives.
To let the rest of the code know about this decision I implemented a wrapper over the Allocator interface which cannot fail.

This is just the first step in the upcoming refactoring attempt.
2024-01-29 17:22:20 +01:00
IntegratedQuantum
178489b044 Merge All ItemSlot types into one struct.
Fixes #240
2024-01-26 00:14:51 +01:00
IntegratedQuantum
4f789c4cca Update zig, forcing constness 2023-11-21 16:23:24 +01:00
IntegratedQuantum
e61709cb69 Rethink the allocation strategy.
Instead of one general purpose allocator per thread, there now is one stack allocator per thread, which behaves like a basic stack.
Using this allocator for all the trivial allocations, makes the game overall more efficient, even if some larger allocations now require going through the global allocator.
Maybe in the future the stack allocator could be extended with a temporary arena allocator functionality?

This should help with #171 by almost halfing the CPU usage of the receiving network thread. However the issue remains.
2023-11-21 16:06:19 +01:00
IntegratedQuantum
f3a197f6d4 Default gui positions
Resolves #131
2023-10-15 22:26:02 +02:00
IntegratedQuantum
cc9a06ef29 Fix some TODOs. 2023-10-06 22:34:36 +02:00
IntegratedQuantum
248691d54d Store key names at runtime instead of at compile time.
Reduces code complexity and binary size.
2023-07-24 11:36:45 +02:00
IntegratedQuantum
7cb347ce3c Update zig to 0.11.0-dev.3990+f2d433a19 2023-07-14 11:24:18 +02:00