Skip to content

Commit f8c0b72

Browse files
committed
improvements
1 parent fd1fe6e commit f8c0b72

File tree

15 files changed

+231
-102
lines changed

15 files changed

+231
-102
lines changed

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,32 @@ class PlayState extends LfState {
5353
A code probably similar to one from [HaxeFlixel](https://haxeflixel.com/) right?
5454

5555
## Current status of the engine:
56-
- [x] Wii U Gamepad support (Touchscreen support partially)
57-
- [x] Sprites
58-
- [x] Texts
59-
- [x] buttons (Partially broken)
60-
- [x] Audio support (Only one music or sound at the same time)
56+
- [x] Wii U Gamepad support
57+
- [x] Wii U Gamepad Buttons and sticks
58+
- [x] Wii U Gamepad Rumble
59+
- [x] Wii U Gamepad Accelerometer
60+
- [x] Wii U Gamepad Gyroscope
61+
- [x] Wii U Gamepad Touchscreen
62+
- [x] Wii U Gamepad Touchscreen touch position and click
63+
- [x] Wii U Gamepad Touchscreen LCD brightness control
64+
- [] Wii U Gamepad Camera
65+
- [] Wii U Gamepad Microphone
66+
- Objects
67+
- [x] Sprites
68+
- [x] Texts
69+
- [x] buttons (Partially broken)
70+
- [x] Audio support with precise control (Only one music or sound at the same time)
6171
- [x] States
72+
- [] Substates
6273
- [x] Collisions
6374
- [x] Sprites basic physics
6475
- [x] Tweens and easing functions
6576
- [x] JSONs file support (Only decoding)
66-
- [x] Timers
77+
- [x] Timers (Using [``haxe.Timer``](https://api.haxe.org/haxe/Timer.html))
6778
- [x] HTTP requests (Via Curl)
6879
- [x] Multiple renders mode (``DRC``, ``TV`` and ``UNIQUE``)
6980
- [x] FileSystem manipulation
70-
- [ ] Cameras
71-
- [ ] Wii U Gamepad Camera support
72-
- [ ] Wii U Gamepad Microphone support
81+
- [] Engine cameras
7382

7483
## How?
7584
This engine uses [SDL2 (For the Wii U)](https://github.com/devkitPro/SDL/tree/wiiu-sdl2-2.28) as a base, along with other WUT functions. All the libraries are ported to Haxe to work through the ``@:native`` feature, to finally use [Reflaxe/C++](https://github.com/SomeRanDev/reflaxe.CPP) to generate the code in C++ and compile it through the [DevKitPPC](https://wiibrew.org/wiki/DevkitPPC) tools, although due to this mode, there are things that change and have more care in how the engine is used when you want to make a project with it.

docs/wiki/sections/FolderSections/Audio.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Leafy.audio.stop();
2424
// Toggle the loop of a sound or music
2525
Leafy.audio.toggleLoop();
2626
27-
// Get the LfAudio object if is already created
28-
var audioObj:LfAudio = Leafy.audio.currentAudio;
27+
// Check if the audio is playing
28+
var isPlaying:Bool = Leafy.audio.playing;
2929
30-
// Or get it as soon as you play the audio
31-
var audioObj:LfAudio = Leafy.audio.play("GAME_PATH/music.ogg", true);
30+
// Check if the audio is paused
31+
var isPaused:Bool = Leafy.audio.paused;
3232
3333
// get the current time of the audio
3434
var currentTime:Float = Leafy.audio.getCurrentTime();

docs/wiki/sections/FolderSections/WiiU_Gamepad.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Well, there is a way of use the gamepad buttons in the engine:
99
import leafy.Leafy;
1010
1111
// get if a button is pressed
12-
var isPressed:Bool = Leafy.gamepad.pressed(BUTTON_A);
12+
var isPressed:Bool = Leafy.wiiuGamepad.pressed(BUTTON_A);
1313
1414
// Get if a button is released
1515
var isReleased:Bool = Leafy.wiiuGamepad.released(BUTTON_A);
@@ -99,4 +99,20 @@ Leafy.wiiuGamepad.stopRumble();
9999

100100
--------
101101

102+
For the screen brightness, it would be done in this way:
103+
```haxe
104+
// import the Leafy class
105+
import leafy.Leafy;
106+
107+
// set the brightness of the screen
108+
Leafy.wiiuGamepad.setScreenBrightness(brightness:LfGamepadScreenBrightness);
109+
Leafy.wiiuGamepad.setScreenBrightness(BRIGHTNESS_3);
110+
111+
// get the brightness of the screen
112+
var brightness:LfGamepadScreenBrightness = Leafy.wiiuGamepad.getScreenBrightness();
113+
```
114+
The brightness modes can be found on the enum [``leafy.gamepad.LfGamepad.LfGamepadScreenBrightness``](https://github.com/Slushi-Github/leafyEngine/blob/main/leafy/gamepad/LfGamepad.hx)
115+
116+
--------
117+
102118
See [``LfGamepad``](https://github.com/Slushi-Github/leafyEngine/blob/main/leafy/gamepad/LfGamepad.hx)

leafy/LfEngine.hx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LfEngine {
3030
/**
3131
* The current version of the engine
3232
*/
33-
public static var version:String = "1.3.5";
33+
public static var version:String = "1.3.7";
3434

3535
/**
3636
* Function to be called when the engine exits
@@ -42,15 +42,20 @@ class LfEngine {
4242
*/
4343
public static var windowMode:LfWindowType;
4444

45+
/**
46+
* The initial state
47+
*/
48+
public static var initState:LfState;
49+
4550
/**
4651
* Is the engine running
4752
*/
4853
private static var _isRunning:Bool = false;
4954

5055
/**
51-
* The initial state
56+
* The initial DRC screen brightness level
5257
*/
53-
public static var initState:LfState;
58+
public static var initBrightness:Int = -1;
5459

5560
/**
5661
* Initialize the engine, and start the state
@@ -86,6 +91,9 @@ class LfEngine {
8691
// Initialize the Wii U Gamepad
8792
LfGamepadInternal.initDRC();
8893

94+
// Get the initial DRC screen brightness level
95+
initBrightness = LfGamepadInternal.getDRCLCDBrightness();
96+
8997
LeafyDebug.log("Leafy Engine " + Std.string(version) + " initialized", INFO);
9098

9199
// Set and initialize the initial state
@@ -109,10 +117,17 @@ class LfEngine {
109117
onEngineExit();
110118
}
111119

120+
if (LfGamepadInternal.getDRCLCDBrightness() != initBrightness) {
121+
// Restore the initial DRC screen brightness level
122+
LfGamepadInternal.setDRCLCDBrightness(initBrightness);
123+
}
124+
112125
LfStateHandler.destroyCurrentState();
113126
SubEngines.shutdownSDL();
114127
LfSystemPaths.deinitFSSystem();
115128
Log_udp.WHBLogUdpDeinit();
116129
Proc.WHBProcShutdown();
130+
LeafyDebug.log("Leafy Engine " + Std.string(version) + " shutdown", INFO);
131+
117132
}
118133
}

leafy/audio/LfAudioEngine.hx

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package leafy.audio;
77

8-
import leafy.backend.internal.LfAudioManager;
8+
import leafy.backend.internal.LfAudioManagerInternal;
99

1010
/**
1111
* Audio engine, handles audio playback
@@ -14,59 +14,76 @@ import leafy.backend.internal.LfAudioManager;
1414
*/
1515
class LfAudioEngine {
1616

17-
public var currentAudio:LfAudio;
17+
/**
18+
* Is the audio currently playing
19+
*/
20+
public var playing:Bool = false;
21+
22+
/**
23+
* Is the audio currently paused
24+
*/
25+
public var paused:Bool = true;
26+
27+
// /**
28+
// * The current audio time
29+
// */
30+
// public var currentTime:Float = 0;
31+
32+
// /**
33+
// * The current audio duration
34+
// */
35+
// public var duration:Float = 0;
1836

1937
/**
2038
* Plays an audio file
2139
* @param path The path to the audio file
2240
* @param loop Whether the audio should loop
2341
*/
24-
public function play(path:String, loop:Bool = false):LfAudio {
25-
currentAudio = LfAudioManager.instance.play(path, loop);
26-
return currentAudio;
42+
public function play(path:String, loop:Bool = false):Void {
43+
LfAudioManagerInternal.instance.play(path, loop);
2744
}
2845

2946
/**
3047
* Pauses the currently playing audio
3148
*/
3249
public function pause():Void {
33-
LfAudioManager.instance.pause();
50+
LfAudioManagerInternal.instance.pause();
3451
}
3552

3653
/**
3754
* Resumes the currently paused audio
3855
*/
3956
public function resume():Void {
40-
LfAudioManager.instance.resume();
57+
LfAudioManagerInternal.instance.resume();
4158
}
4259

4360
/**
4461
* Stops the currently playing audio
4562
*/
4663
public function stop():Void {
47-
LfAudioManager.instance.stop();
64+
LfAudioManagerInternal.instance.stop();
4865
}
4966

5067
/**
5168
* Toggles the loop state of the currently playing audio
5269
*/
5370
public function toggleLoop():Void {
54-
LfAudioManager.toggleLoop();
71+
LfAudioManagerInternal.toggleLoop();
5572
}
5673

5774
/**
5875
* Gets the current audio time
5976
* @return Float
6077
*/
6178
public function getCurrentTime():Float {
62-
return LfAudioManager.getCurrentTime();
79+
return LfAudioManagerInternal.getCurrentTime();
6380
}
6481

6582
/**
6683
* Gets the current audio duration
6784
* @return Float
6885
*/
6986
public function getDuration():Float {
70-
return LfAudioManager.getDuration();
87+
return LfAudioManagerInternal.getDuration();
7188
}
7289
}

leafy/backend/LeafyDebug.hx

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import wiiu.SDCardUtil;
1414
import wut.coreinit.Time.OSCalendarTime;
1515
import wut.coreinit.Debug;
1616

17-
import notifications.Notifications;
18-
import notifications.Notification_defines.NMColor;
19-
2017
import leafy.filesystem.LfFile;
2118
import leafy.filesystem.LfSystemPaths;
2219
import leafy.utils.LfStringUtils;
@@ -93,16 +90,6 @@ class LeafyDebug {
9390
*/
9491
private static var started:Bool = false;
9592

96-
/**
97-
* The background color of the notification
98-
*/
99-
private static var notificationBGColor:NMColor = new NMColor();
100-
101-
/**
102-
* The text color of the notification
103-
*/
104-
private static var notificationTextColor:NMColor = new NMColor();
105-
10693
/**
10794
* // Log a message
10895
* @param msg The message
@@ -114,30 +101,6 @@ class LeafyDebug {
114101
return;
115102
}
116103

117-
switch (level) {
118-
case LogLevel.INFO:
119-
// Do nothing
120-
case LogLevel.WARNING:
121-
notificationBGColor.r = 152;
122-
notificationBGColor.g = 93;
123-
notificationBGColor.b = 0;
124-
Notifications.NotificationModule_AddInfoNotificationEx(ConstCharPtr.fromString(msg), 3, notificationTextColor, notificationBGColor, untyped __cpp__("nullptr"), untyped __cpp__("nullptr"), false);
125-
case LogLevel.ERROR:
126-
notificationBGColor.r = 237;
127-
notificationBGColor.g = 28;
128-
notificationBGColor.b = 36;
129-
Notifications.NotificationModule_AddErrorNotificationEx(ConstCharPtr.fromString(msg), 3, 0.8, notificationTextColor, notificationBGColor, untyped __cpp__("nullptr"), untyped __cpp__("nullptr"), false);
130-
case LogLevel.DEBUG:
131-
notificationBGColor.r = 104;
132-
notificationBGColor.g = 0;
133-
notificationBGColor.b = 93;
134-
Notifications.NotificationModule_AddInfoNotificationEx(ConstCharPtr.fromString(msg), 3, notificationTextColor, notificationBGColor, untyped __cpp__("nullptr"), untyped __cpp__("nullptr"), false);
135-
case LogLevel.CRITICAL:
136-
// Do nothing
137-
default:
138-
// Do nothing
139-
}
140-
141104
var formattedMessage:String = prepareText(msg, level, pos);
142105

143106
if (!started) {
@@ -172,11 +135,6 @@ class LeafyDebug {
172135
LfSystemPaths.createDirectory(logsDir);
173136
}
174137

175-
notificationTextColor.r = 255;
176-
notificationTextColor.g = 255;
177-
notificationTextColor.b = 255;
178-
notificationTextColor.a = 255;
179-
180138
var currentTimeStr:String = untyped __cpp__("CPP_getCurrentTime()");
181139
var currentTimeMod:String = currentTimeStr;
182140
currentTimeMod = LfStringUtils.stringReplacer(currentTimeMod, ":", "_");

leafy/backend/LfJson.hx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ class LfJson {
5353
* @param jsonPath
5454
* @return LeafyJson
5555
*/
56-
public static function parseJsonFile(jsonPath:String):LeafyJson {
57-
58-
var correctPath:String = LfSystemPaths.getConsolePath() + jsonPath;
56+
public static function parseJsonFile(jsonPath:String, absolutePath:Bool = false):LeafyJson {
57+
var correctPath:String = "";
58+
if (absolutePath) {
59+
correctPath = jsonPath;
60+
} else {
61+
correctPath = LfSystemPaths.getEngineMainPath() + jsonPath;
62+
}
5963

6064
if (jsonPath == null || jsonPath == "") {
6165
LeafyDebug.log("JSON file path cannot be null or empty", ERROR);
@@ -65,7 +69,6 @@ class LfJson {
6569
if (!LfSystemPaths.exists(correctPath) || !LfStringUtils.stringEndsWith(correctPath, ".json")) {
6670
LeafyDebug.log("JSON file does not exist or is not a valid JSON file", ERROR);
6771
return null;
68-
6972
}
7073

7174
var rawJSONError:Json_error_t = new Json_error_t();

leafy/backend/SubEngines.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import sdl2.SDL_Error;
1111
import sdl2.SDL;
1212

1313
import leafy.backend.sdl.LfWindow;
14-
import leafy.backend.internal.LfAudioManager;
14+
import leafy.backend.internal.LfAudioManagerInternal;
1515

1616
/**
1717
* A class for initializing the SDL libraries
@@ -52,8 +52,8 @@ class SubEngines {
5252
}
5353

5454
// Init SDL Audio Engine
55-
new LfAudioManager();
56-
LfAudioManager.init();
55+
new LfAudioManagerInternal();
56+
LfAudioManagerInternal.init();
5757

5858
LeafyDebug.log("SDL_Audio initialized", INFO);
5959
}
@@ -65,7 +65,7 @@ class SubEngines {
6565
*/
6666
public static function shutdownSDL():Void {
6767
LfWindow.closeEngineWindows();
68-
LfAudioManager.shutdown();
68+
LfAudioManagerInternal.shutdown();
6969

7070
SDL_TTF.TTF_Quit();
7171
SDL_Image.IMG_Quit();

0 commit comments

Comments
 (0)