List of commits:
Subject Hash Author Date (UTC)
Add vnDrawStats 51ac185dc323ea564d60ef3bb675ab0855a966f7 mse 2022-09-05 09:10:33
Add cave-confec-gl2 targets (WIP) c89db928efc4b68d42d9b66079e444decedc49e2 mse 2022-08-16 04:24:50
Simplify debug target d55157f6ff96ec2103b2d703b96925b767c08ce2 mse 2022-08-16 03:45:00
Bump version to 0.8.0 6f5adaa7a93dff9a24ba03aef36f620d153816f4 mse 2022-08-08 12:16:23
Default saves to ./userdata and replace optional --savehere arg with --saveinos d0cb1ab86c2110cdc0f2aba19fc3843902d6a5ea mse 2022-08-08 11:42:21
Enable Chinese image buttons 3129899ee20ee1821b13db063dcd83477e37c505 mse 2022-08-06 04:44:38
Expand Chinese translations 2baa34f7247c32af12480feb801cb41787022115 mse 2022-08-04 18:34:02
Add VNHACK command 4539d3931617e58e73b295d6ca3679150acdcf78 mse 2022-08-04 06:59:04
Refactor FG3 to allow separate compilation eb1bb8bbc8c60169c2bbd789b38c608b4bb9cbab mse 2022-08-03 22:30:45
Fix menu bugs and bump to v0.7.11 ae193263f4b8461c299f6db66f130beae94724cc mse 2022-07-07 04:52:30
Bump version to 0.7.10 5f70f1aba48d3df67d5e4a70d9595e92aeac4afb mse 2022-05-11 10:54:09
ADV-style text advance 5fbb734d07a2dcf0162245b5afc6b5b4b9021b6f mse 2022-04-12 12:25:24
Switch interaction to mouse-up 345ce8d1ea9755f51365a2676cce0415f9cf68c2 mse 2022-04-10 21:07:15
Use gradient for text backdrop 6ad98cdaf4df37e8b24d9c1e8e2f9b0e904da9aa mse 2022-04-10 13:04:29
Improve vn button highlight 51b2c6c07b0cfb0efdb8cdf5cbeba49ef54d9ccb mse 2022-04-09 06:54:39
Darken the screen when drawing a menu with non-VN text 8f3bcee6d57817ea8c1dd999c68cb129dea1550c mse 2022-04-08 16:01:52
Upgrade the UI 45561487af001c5a790343690a792faeb14945d4 mse 2022-04-06 23:45:31
Progress on getting Emscripten builds working again (almost) e4276b7823027c7ac3a3afe30c3c30241f1c6642 mse 2022-04-01 11:16:56
Bump to version 0.7.9 1c93b011603bd953df0628fa39c586c11eeb7138 mse 2022-03-30 08:31:00
Some progress on Android support dd2d0eb6d4ee42149b605526ce304e67243d90b4 mse 2022-03-20 00:28:35
Commit 51ac185dc323ea564d60ef3bb675ab0855a966f7 - Add vnDrawStats
Author: mse
Author date (UTC): 2022-09-05 09:10
Committer name: mse
Committer date (UTC): 2022-09-05 09:10
Parent(s): c89db928efc4b68d42d9b66079e444decedc49e2
Signer:
Signing key:
Signing status: N
Tree: c3eccc51d5c42b640b54b09149238c0195d78c7f
File Lines added Lines deleted
include/vn.h 111 11
File include/vn.h changed (mode: 100644) (index 08ceef6..6c1a55a)
... ... void vnGo( dialogue::Talk &convo, const std::string &id );
20 20 // Width and height of the VN. Graphics will be scaled from this to screen size. // Width and height of the VN. Graphics will be scaled from this to screen size.
21 21 double vn_width = 1366.0, vn_height = 768.0; double vn_width = 1366.0, vn_height = 768.0;
22 22
23 // UI meshes.
24 fgl::Mesh vn_mesh_plane;
25
23 26 // Common VN UI textures. Loaded automatically. // Common VN UI textures. Loaded automatically.
24 27 fgl::Texture vn_tex_shade = {}, vn_tex_gradient = {}, vn_tex_button_n = {}, vn_tex_button_p = {}, vn_tex_button_s = {}; fgl::Texture vn_tex_shade = {}, vn_tex_gradient = {}, vn_tex_button_n = {}, vn_tex_button_p = {}, vn_tex_button_s = {};
25 28
 
... ... void vnLoadUITextures(
53 56 const std::string &buttonN, const std::string &buttonN,
54 57 const std::string &buttonP, const std::string &buttonP,
55 58 const std::string &buttonS ){ const std::string &buttonS ){
59 vn_mesh_plane = fgl::getPlaneMesh();
56 60 vn_tex_gradient = vnLoadImage( dataPath + "/" + gradient, true, true ); vn_tex_gradient = vnLoadImage( dataPath + "/" + gradient, true, true );
57 61 vn_tex_button_n = vnLoadImage( dataPath + "/" + buttonN, true, true ); vn_tex_button_n = vnLoadImage( dataPath + "/" + buttonN, true, true );
58 62 vn_tex_button_p = vnLoadImage( dataPath + "/" + buttonP, true, true ); vn_tex_button_p = vnLoadImage( dataPath + "/" + buttonP, true, true );
 
... ... void vnDrawImage( fgl::Texture &tex, float posX, float posY, float angle, float
65 69 double textureWidth = tex.width, textureHeight = tex.height; double textureWidth = tex.width, textureHeight = tex.height;
66 70 fgl::setTexture( tex, 0 ); fgl::setTexture( tex, 0 );
67 71 fgl::drawMesh( fgl::drawMesh(
68 fgl::planeMesh,
72 vn_mesh_plane,
69 73 linalg::mul( linalg::mul(
70 74 linalg::translation_matrix( linalg::vec<double,3>( linalg::translation_matrix( linalg::vec<double,3>(
71 75 ( textureWidth * 0.5 * scaleX + posX ) / screenHeight * 2.0 - screenWidth / screenHeight, ( textureWidth * 0.5 * scaleX + posX ) / screenHeight * 2.0 - screenWidth / screenHeight,
 
... ... void vnFreeImages(){
115 119 vn_foregrounds = {}; vn_foregrounds = {};
116 120 } }
117 121
122 // TODO: ADV auto mode
123 void vnDrawStats( fgl::Font &font, dialogue::Talk &convo ){
124 double sw = fgl::getDisplayWidth(), sh = fgl::getDisplayHeight();
125 double aspect = sw / sh;
126 double vnScale = sw / vn_width;
127 double vnOffX = 0.0;
128 double vnMinAspect = 5.0 / 4.0, vnMaxAspect = 1.78;
129 if( aspect < vnMinAspect ){
130 vnScale = sh * vnMinAspect / vn_width;
131 vnOffX = ( sw - sh * vnMinAspect ) * 0.5;
132 }else if( aspect > vnMaxAspect ){
133 vnScale = sh * vnMaxAspect / vn_width;
134 vnOffX = ( sw - sh * vnMaxAspect ) * 0.5;
135 }
136
137 // Assume at least 720p and a maximum of exactly 500 stat points.
138 float bar_pixels = 227.0f;
139 float bar_factor = 0.454f;
140
141 // Draw the stats listed in the showstats array.
142 float tw = 0.0f;
143 auto showstats_it = convo.arrays.find( "showstats" );
144 if( showstats_it != convo.arrays.end() ){
145 for( auto &stat : showstats_it->second ){
146 tw = std::max(tw, fgl::getTextWidth(convo.strings[stat], font));
147 }
148 }
149 if( tw > 0.0f ){
150 float bw = tw + bar_pixels + font.size * 1.76944f;
151 float x = vnOffX + ( vn_width - bw - font.size * 1.05) * vnScale;
152 float y = font.size * 1.333 * vnScale;
153 float box_h =
154 showstats_it->second.size() * font.size * 1.333 * vnScale;
155 vnDrawImage(
156 vn_tex_shade,
157 x,
158 y,
159 0.0,
160 bw * vnScale,
161 box_h
162 );
163 for( auto &stat : showstats_it->second ){
164 double points = convo.numbers[stat];
165 // Draw bar.
166 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
167 float bar_x = std::floor( x + ( tw + 5.0 ) * vnScale );
168 float bar_y = std::floor( y + font.size * 0.1665 * vnScale );
169 float bar_w =
170 std::ceil( std::max(points * bar_factor, 1.0) * vnScale ) / fgl::blankTexture.width;
171 float bar_h = std::floor( font.size * vnScale ) / fgl::blankTexture.height;
172 fgl::setFog( { 0.2f, 0.0f, 0.0f, 1.0f } );
173 vnDrawImage( fgl::blankTexture, bar_x, bar_y, 0.0, std::ceil( bar_pixels * vnScale ) / fgl::blankTexture.width, bar_h );
174 // Lines.
175 fgl::setFog( { 0.65f, 0.6f, 0.6f, 1.0f } );
176 for( int i = 1; i < 5; i++ ){
177 vnDrawImage(
178 fgl::blankTexture,
179 std::floor( bar_x + (i * bar_pixels * 0.25 - 2.0) * vnScale ),
180 bar_y,
181 0.0,
182 std::ceil( vnScale ) / fgl::blankTexture.width,
183 bar_h + std::floor( 2.0 * vnScale )
184 );
185 }
186 // Bar.
187 fgl::setFog( { 0.9f, 0.0f, 0.0f, 1.0f } );
188 vnDrawImage( fgl::blankTexture, bar_x, bar_y, 0.0, bar_w, bar_h );
189 fgl::setFog( { 1.0f, 0.0f, 0.0f, 1.0f } );
190 vnDrawImage( fgl::blankTexture, bar_x, bar_y, 0.0, bar_w, bar_h * 0.65 );
191 fgl::setFog( { 1.0f, 0.33f, 0.33f, 1.0f } );
192 vnDrawImage( fgl::blankTexture, bar_x, bar_y + bar_h * 0.15, 0.0, bar_w, bar_h * 0.15 );
193 // Draw text.
194 glBlendFunc( GL_ONE, GL_ONE );
195 fgl::setFog( { 1.0f, 1.0f, 1.0f, 1.0f } );
196 fgl::drawText(
197 convo.strings[stat],
198 font,
199 x + 3.0 * vnScale,
200 y,
201 vnScale
202 );
203 fgl::drawText(
204 convo.stringifyNumber( points ),
205 font,
206 x + ( bw - 3.0 ) * vnScale,
207 y,
208 vnScale,
209 2
210 );
211 y += font.size * 1.333 * vnScale;
212 }
213 }
214 }
215
118 216 // Draw the VN. Return true if a selection was made. // Draw the VN. Return true if a selection was made.
119 217 bool vnDraw( bool vnDraw(
120 218 const std::string &dataPath, const std::string &dataPath,
 
... ... bool vnDraw(
252 350 } }
253 351 } }
254 352
353 int mouseX = fgl::getMouseX(), mouseY = fgl::getMouseY();
354
255 355 if( convo.screen.lines.empty() ){ if( convo.screen.lines.empty() ){
256 356 // Handle button-free screen advance. // Handle button-free screen advance.
257 357 if( convo.screen.ids.size() > 0 ) choiceIndex = 0; if( convo.screen.ids.size() > 0 ) choiceIndex = 0;
 
... ... bool vnDraw(
269 369 float xpos = ( sw - total_width * vnScale ) * 0.5; float xpos = ( sw - total_width * vnScale ) * 0.5;
270 370 float ypos = vn_height * 0.7409 * vnScale; float ypos = vn_height * 0.7409 * vnScale;
271 371 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
272 fgl::setPipeline( fgl::unlitPipeline );
372 fgl::setPipeline( fgl::getUnlitPipeline() );
273 373 for( size_t i = 0; i < img_buttons.size(); i++ ){ for( size_t i = 0; i < img_buttons.size(); i++ ){
274 374 auto w = img_buttons[i]->width, h = img_buttons[i]->height; auto w = img_buttons[i]->width, h = img_buttons[i]->height;
275 375 bool hover = bool hover =
276 376 useMouse && useMouse &&
277 fgl::mouseY >= ypos &&
278 fgl::mouseY < ypos + ( h + 2.0 ) * vnScale &&
279 fgl::mouseX >= xpos &&
280 fgl::mouseX < xpos + ( w + 2.0 ) * vnScale;
377 mouseY >= ypos &&
378 mouseY < ypos + ( h + 2.0 ) * vnScale &&
379 mouseX >= xpos &&
380 mouseX < xpos + ( w + 2.0 ) * vnScale;
281 381 if( hover ){ if( hover ){
282 382 choiceIndex = i; choiceIndex = i;
283 383 } }
 
... ... bool vnDraw(
314 414 ); );
315 415 xpos += ( w + 2.0 ) * vnScale; xpos += ( w + 2.0 ) * vnScale;
316 416 } }
317 fgl::setPipeline( fgl::colorModPipeline );
417 fgl::setPipeline( fgl::getColorModPipeline() );
318 418 fgl::setFog( { 1.0f, 1.0f, 1.0f, 1.0f } ); fgl::setFog( { 1.0f, 1.0f, 1.0f, 1.0f } );
319 419 }else{ }else{
320 420 // Draw text buttons. // Draw text buttons.
 
... ... bool vnDraw(
331 431 float ypos = ( vn_height * 0.7409 + buttonHeight * (float)i ) * vnScale; float ypos = ( vn_height * 0.7409 + buttonHeight * (float)i ) * vnScale;
332 432 bool hover = bool hover =
333 433 useMouse && useMouse &&
334 fgl::mouseY >= ypos &&
335 fgl::mouseY < ( vn_height * 0.7409 + buttonHeight * (float)( i + 1 ) ) * vnScale &&
336 fgl::mouseX >= vnOffX &&
337 fgl::mouseX < vnOffX + vn_width * vnScale;
434 mouseY >= ypos &&
435 mouseY < ( vn_height * 0.7409 + buttonHeight * (float)( i + 1 ) ) * vnScale &&
436 mouseX >= vnOffX &&
437 mouseX < vnOffX + vn_width * vnScale;
338 438 if( hover ){ if( hover ){
339 439 choiceIndex = i; choiceIndex = i;
340 440 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using git:
git clone git://git.rocketgit.com/user/mse/ConfectionerEngine

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main