238 void DrawWideBackground(
u8 red,
u8 green,
u8 blue);
264 void TranslateInput(
float seconds,
const PaintShopInput &input,
bool dialog);
265 bool DialogShows()
const;
266 void Transfer(
u32 mask);
268 void CheckStick(
s32 &timer,
f32 axis,
f32 sign,
u32 button);
273 void SelectDecalTexels(
int slot);
274 void SetUpPaintShopCar();
275 void LoadDecalSlotIcons();
276 void LayOutPaintShopButtons();
277 void LoadPaintToolIcons();
278 void LoadStyleIcons();
279 void LayOutPaintShopControls();
280 bool InitPaintShop();
281 void DrawPaintShopButton(
const PaintRect &rect,
u8 red,
u8 green,
u8 blue);
283 void DrawPaintShop();
284 void DrawToolCursor();
285 void RunPaintShopPakDialog(
u8 operation);
286 void RunPaintShopMenus();
287 void HandlePaintShopB();
291 void RedoDecalEdit();
292 void DrawDialogBox(
s32 x,
s32 y,
s32 width,
s32 height);
293 void DrawSunkenFrame(
s32 x,
s32 y,
s32 width,
s32 height);
294 void SetPakTextColors(
u8 inCarSelect);
296 void DrawMenuButtons(
s32 buttonY,
s32 cancelX);
297 void ClearDecal(
u8 coloredOption);
303 void CopyUnmaskedTexels(
u8 *texels,
const u8 *mask,
s32 width,
s32 height);
304 void TransferDecal(
DecalCar &car,
u8 operation);
306 void DrawPakButtons(
s32 buttonY,
u32 okTextX,
u32 cancelTextX,
s32 okX,
s32 cancelX);
309 void PressKeyboardKey(
u8 key);
310 void TypeOnKeyboard();
313 void SelectDecalSlot(
s32 slot);
314 bool HasOppositePanel(
int slot)
const;
316 void LayOutDecalCanvas();
319 s32 AnchorDistance()
const;
323 bool PickDecalSlot();
324 bool PickPaletteColor();
325 bool PickPaintTool();
326 void ProcessTextTool();
329 void PaintRectangle();
331 bool PaintWithTool();
332 void DrawShapeOutline();
339 void MoveStyleMenuCursor();
346 void SetPalette(
int entry,
u8 red,
u8 green,
u8 blue);
347 void CopyLightPalettes();
348 void PickMenuOption(
const PaintRect *options,
int count,
u8 &cursor);
366 void AdvanceDashes();
373 s32 ScreenToTexelX(
s32 x)
const;
374 s32 ScreenToTexelY(
s32 y)
const;
375 u8 FontTexel(
s32 column,
s32 row)
const;
376 s32 GlyphAdvance(
int glyph,
int next)
const;
394 std::string m_typedText;
395 s32 m_frameMilliseconds = 0;
398 float m_consoleFrameTime = 0.0f;
399 bool m_consoleFrame =
true;
401 std::array<int, 2> m_pointer{};
402 bool m_pointerMoved =
false;
403 bool m_pointerSeen =
false;
404 bool m_escapeDown =
false;
407 std::map<u32, PaintSprite> m_sprites;
408 PaintSprite *m_background =
nullptr;
409 PaintSprite *m_logo =
nullptr;
410 PaintSprite *m_paintWholeCar =
nullptr;
411 PaintSprite *m_panel8Overlay =
nullptr;
412 PaintSprite *m_panel9Overlay =
nullptr;
413 PaintSprite *m_brushSizeRound =
nullptr;
414 PaintSprite *m_brushSizeSquare =
nullptr;
415 PaintSprite *m_paintCursor =
nullptr;
416 PaintSprite *m_fillCursor =
nullptr;
417 PaintSprite *m_brushCursor =
nullptr;
418 PaintSprite *m_crosshairCursor =
nullptr;
419 PaintSprite *m_textCursor =
nullptr;
420 PaintSprite *m_eyedropperCursor =
nullptr;
421 PaintSprite *m_keyboardPanel =
nullptr;
422 PaintSprite *m_keyboardBackground =
nullptr;
423 PaintSprite *m_keyboardHighlight =
nullptr;
424 PaintSprite *m_buttonA =
nullptr;
425 PaintSprite *m_buttonB =
nullptr;
426 PaintSprite *m_decalFont =
nullptr;
427 PaintSprite *m_shapeFilledCircle =
nullptr;
428 std::array<PaintSprite *, DECAL_SLOTS> m_decalSlotIcons{};
429 std::array<PaintSprite *, 13> m_paintToolIcons{};
430 std::array<PaintSprite *, 4> m_rectStyleIcons{};
431 std::array<PaintSprite *, 4> m_ovalStyleIcons{};
434 PaintRect m_decalCanvasFrame;
435 PaintRect m_paletteFrameLeft;
436 PaintRect m_paletteFrameRight;
437 std::array<PaintRect, 5> m_brushSizeRects{};
438 std::array<PaintRect, 5> m_brushSizeButtonRects{};
439 std::array<PaintGlyph, 50> m_decalGlyphs{};
440 std::array<std::array<u8, 3>, 3> m_colorEditorBars{};
441 std::array<std::string, 3> m_colorChannelNames;
442 std::array<std::string, 2> m_brushStyleNames;
443 std::array<std::string, 2> m_textStyleNames;
444 std::array<std::string, 4> m_rectStyleNames;
445 std::array<std::string, 4> m_ovalStyleNames;
446 std::array<PaintVector, DECAL_SLOTS> m_panelViewDirections{};
449 std::optional<DecalCar> m_car;
451 bool m_initialized =
false;
452 bool m_previewDirty =
true;
453 int m_previewWait = 0;
454 std::unique_ptr<RenderModel> m_preview;
455 std::unique_ptr<RenderTexture> m_previewReflection;
456 PaintVector m_frameForward;
457 PaintVector m_frameUp;
458 PaintVector m_frameSide;
459 PaintVector m_framePosition;
460 PaintVector m_cameraPosition;
461 std::array<PaintSwatch, 16> m_swatches{};
462 std::array<PaintRect, 13> m_paintToolButtonRects{};
463 std::array<PaintRect, DECAL_SLOTS> m_decalSlotRects{};
464 PaintRect m_decalCanvas;
466 std::array<int, 16> m_decalTextGlyphs{};
467 std::string m_decalText;
468 std::vector<u8> m_undoBuffer;
469 std::vector<std::vector<u8>> m_undoHistory;
470 std::vector<std::vector<u8>> m_redoHistory;
471 std::optional<std::vector<u8>> m_colorEditorSnapshot;
472 std::vector<u8> m_savedEditableData;
473 std::vector<u8> m_scratchTexels;
474 u8 *m_decalTexels =
nullptr;
475 const u8 *m_decalTexelsEnd =
nullptr;
476 const u8 *m_decalMask =
nullptr;
477 int m_decalPaletteMaterial = 0;
480 u8 m_decalHeight = 0;
486 u8 m_textShadowColor = 0;
488 u8 m_previousPaintTool = 0;
490 u8 m_previousDecalSlot = 0;
491 u8 m_savedDecalSlot = 0;
492 u8 m_decalTextLength = 0;
493 u8 m_decalTextWidth = 0;
494 u8 m_styleMenuCursor = 0;
495 u8 m_paintToolStarted = 0;
496 u8 m_decalDragActive = 0;
497 u8 m_paletteEnabled = 0;
498 u8 m_decalSlotHasMirror = 0;
499 u8 m_decalSlotChanged = 0;
500 u8 m_colorEditorOpen = 0;
501 u8 m_styleMenuOpen = 0;
502 u8 m_textShadowPickerOpen = 0;
503 u8 m_paintShopExiting = 0;
504 u8 m_colorEditorChannel = 0;
505 u8 m_keyboardHoverKey = 0;
506 u8 m_showPreview3D = 0;
507 u8 m_eyedropperActive = 0;
508 u8 m_mirrorTargetPanel = 0;
509 std::array<u8, 3> m_savedSwatchColor{};
510 s32 m_paintAnchorX = 0;
511 s32 m_paintAnchorY = 0;
512 bool m_constrainShape =
false;
513 u32 m_lastClickTime = 0;
514 bool m_anchorXInitialized =
false;
515 bool m_anchorYInitialized =
false;
516 u16 m_screenFrameCount = 0;
517 s32 m_controllerPakState = 0;
520 u8 m_pakDialogActive = 0;
521 u8 m_pakFileNeedsCreate = 0;
522 u8 m_pakDialogState = 0;
523 u8 m_pakDecalIndex = 0;
524 u8 m_pakWaitFrames = 0;
525 s32 m_pakFileOffset = 0;
527 s32 m_pakChunkSize = 0;
528 std::vector<u8> m_pakNote;
529 bool m_pakDone =
false;
The notes of a Controller Pak, stored in a directory, with the settings note in another.
Definition controllerpak.h:41
Editable console body materials or numbered image layers for an imported car.
Definition decalcar.h:48
PaintShop & operator=(const PaintShop &)=delete
Prevent assignment of active editing and preview resources.
~PaintShop()
Release paint previews and editing resources before the menu screen and GPU device.
friend class Menus
Definition paintshop.h:193
void SetCar(int car, const std::filesystem::path &directory)
Choose the car the paint shop opens with, as the car select screen exits to it.
static std::unique_ptr< PaintShop > Load(SceneRenderer &renderer, const std::filesystem::path &release, MenuScreen &screen, std::optional< std::array< int, 6 > > &textColors, ControllerPak pak)
Read the pictures and the tables of the paint shop from the import of a release.
bool LoadDecalsQuietly(DecalCar &car)
Load the decals of the Controller Pak into a car at once, without the dialog, for the custom decals a...
std::optional< bool > LoadDecalsFrame(SceneRenderer &renderer, float seconds, const PaintShopInput &input, DecalCar &car)
Run a frame of the dialog that loads the decals on the car select screen, as the car select screen of...
bool Frame(SceneRenderer &renderer, float seconds, const PaintShopInput &input)
Run a frame of the paint shop and draw it.
PaintShop(const PaintShop &)=delete
Prevent copying active editing and preview resources.
The renderer of a frame.
Definition scenerenderer.h:467
The Controller Pak of the first controller of the console as a directory of the game,...
Editable car textures reconstructed from imported glTF or GLB assets.
void DrawDashedRoundedRect(s32 x0, s32 y0, s32 x1, s32 y1)
Draw the dashed outline of a rectangle with rounded corners.
void StrokeDecalRectangle(s32 x0, s32 y0, s32 x1, s32 y1)
Paint the outline of a rectangle with the brush.
void FillDecalRoundRect(s32 x0, s32 y0, s32 x1, s32 y1)
Fill a rectangle with rounded corners.
void FillRect4Bit(s32 x0, s32 y0, s32 x1, s32 y1)
Fill a rectangle, excluding its far column and row.
void FillCircle4Bit(s32 x, s32 y, s32 radius, u8 fromScreen)
Fill a circle.
void EmitScaledTextureRect(s32 textureWidth, s32 textureHeight, s32 x, s32 y, s32 width, s32 height)
Draw the texture already loaded over a rectangle of the screen, upside down: the decal being edited.
void DrawDecalFilledEllipse(s32 x0, s32 y0, s32 x1, s32 y1)
Fill the ellipse in a rectangle.
void FloodFill4Bit(s32 x, s32 y)
Fill the area of the color under a point with the color painted with.
void DrawDecalTextPreview(s32 x, s32 y)
Draw the text not yet painted on the screen, centered on a point, with its shadow when the text tool ...
void SetPixel4Bit(s32 x, s32 y, u8 color)
Write a texel of the decal being edited, unless it is outside the decal or the mask protects it.
void DrawLine4Bit(s32 x0, s32 y0, s32 x1, s32 y1)
Paint a line with the brush.
void DrawDashedRectangle(s32 x0, s32 y0, s32 x1, s32 y1)
Draw the dashed outline of a rectangle.
u8 GetPixel4Bit(s32 x, s32 y)
Read a texel of the decal being edited.
void DrawDecalCircleOutline(s32 x, s32 y, s32 radius)
Paint the outline of a circle with the brush.
void DrawDashedCircle(s32 x, s32 y, s32 radius)
Draw the dashed outline of a circle, the part over the decal only.
u8 ReadPixel4Bit(u8 *texels, s32 x, s32 y)
Read a texel of a decal the size of the one being edited.
void DrawDecalRoundedRectOutline(s32 x0, s32 y0, s32 x1, s32 y1)
Paint the outline of a rectangle with rounded corners with the brush.
void DrawDashedEllipse(s32 x0, s32 y0, s32 x1, s32 y1)
Draw the dashed outline of the ellipse in a rectangle.
void DrawDashedLine(s32 x0, s32 y0, s32 x1, s32 y1)
Draw the dashed line from the first point of a line to the cursor.
void StampTextOnDecal(s32 x, s32 y)
Paint the text into the decal, centered on a point, with its shadow when the text tool has it.
void DrawDecalEllipseOutline(s32 x0, s32 y0, s32 x1, s32 y1)
Paint the outline of the ellipse in a rectangle with the brush.
void ProcessPaintShopExitConfirm(void)
Run one frame of the dialog that warns of edits not saved on exit from the paint shop,...
void ProcessBrushStyleMenu(void)
Run one frame of the menu of the styles of the brush tool.
void UndoDecalEdit(void)
Restore the copy of the decal saved for undo.
void SaveDecalUndo(void)
Save a copy of the decal being edited for undo, and count an edit.
void ConvertPaletteToRgb(void)
Set the colors of the swatches from the palette of the decal.
s32 IsCursorInRect(ScreenRect *rect)
Whether the cursor is in a rectangle.
s32 IsCursorInButton(Sprite *sprite)
Whether the cursor is on a sprite as it is drawn.
void ProcessRectStyleMenu(void)
Run one frame of the menu of the styles of the rectangle tool.
void ProcessColorEditorDialog(void)
Run one frame of the color editor of the color in use.
void DrawDecalColorPalette(void)
Draw the palette, with the color in use outlined.
s32 IsCursorOnKeyboardKey(DecalGlyph *key)
Whether the cursor is on a key of the keyboard.
void ProcessDecalEditorInput(void)
Deal with a frame of the input of the decal editor: the decals, the palette, the tools and painting.
void UpdateCursorFromInput(void)
Move the cursor by the stick, the D-pad and the C buttons.
void ProcessTextStyleMenu(void)
Run one frame of the menu of the styles of the text tool, and of its colors of the shadow.
void ProcessTextInputKeyboard(void)
Run one frame of the keyboard of the text tool.
void ProcessOvalStyleMenu(void)
Run one frame of the menu of the styles of the oval tool.
void ProcessMirrorFlipMenu(void)
Run one frame of the menu of the mirror tool.
void FlipDecalPixels(void)
Flip the decal being painted by the choice of the menu of the mirror tool.
void DrawPakErrorMessage(s32 error, u8 operation, u8 inCarSelect)
Draw the message of an error of the controller pak in a box.
void ProcessFillClearMenu(void)
Run one frame of the menu of the clear tool.
void RenderDecalPreview3D(void)
Draw the car beside the decal, turning to the decal slot when it changes.
void ResetPaintShopState(void)
Set the tools, the colors, and the cursor back to their state on entering the paint shop.
void MirrorDecalToOppositePanel(void)
Copy the decal being painted mirrored to the slot on the other side of the car, and paint that slot n...
s32 ProcessDecalSaveLoad(VehicleModel *model, u8 player, u8 operation, u8 inCarSelect, u8 *done)
Run one frame of the dialog that loads the decals of a model from the controller pak or saves them to...
Definition assetimport.h:11
std::array< float, 16 > Matrix4
A 4 by 4 matrix, column by column.
Definition scenerenderer.h:28
PaintTool
The tools of the paint shop, each a button, as the console numbers them.
Definition paintshop.h:34
@ PAINT_TOOL_LINE
Definition paintshop.h:38
@ PAINT_TOOL_LOAD
Definition paintshop.h:44
@ PAINT_TOOL_MIRROR
Definition paintshop.h:42
@ PAINT_TOOL_OVAL
Definition paintshop.h:41
@ PAINT_TOOL_RECTANGLE
Definition paintshop.h:40
@ PAINT_TOOL_UNDO
Definition paintshop.h:46
@ PAINT_TOOL_CLEAR
Definition paintshop.h:43
@ PAINT_TOOL_TEXT
Definition paintshop.h:39
@ PAINT_TOOL_FILL
Definition paintshop.h:37
@ PAINT_TOOL_BRUSH
Definition paintshop.h:36
@ PAINT_TOOL_EXIT
Definition paintshop.h:47
@ PAINT_TOOL_SAVE
Definition paintshop.h:45
@ PAINT_TOOLS
Definition paintshop.h:48
@ PAINT_TOOL_BRUSH_SIZE
Definition paintshop.h:35
The renderer of the converted models and of flat pictures and text, on the GPU of SDL.
void DrawSpriteRegion(Sprite *sprite, s32 x, s32 y, s32 width, s32 height, u8 red, u8 green, u8 blue)
Draw a sprite stretched over a rectangle in a colour.
void DrawScaledTexturedRect(Sprite *sprite, s32 srcX, s32 srcY, s32 srcWidth, s32 srcHeight, s32 x, s32 y, s32 width, s32 height, u8 red, u8 green, u8 blue)
Draw a rectangle of the texels of a 4-bit sprite stretched over a rectangle of the screen in a colour...
void DrawFilledRectHiRes(s32 x, s32 y, s32 width, s32 height, u8 red, u8 green, u8 blue)
Fill a rectangle in a colour.
void DrawRectOutline(s32 x, s32 y, s32 width, s32 height, s32 thickness, u8 red, u8 green, u8 blue)
Draw the outline of a rectangle in a colour, inside its edges.
void DrawTexturedSprite(Sprite *sprite, s32 x, s32 y)
Draw a sprite at a position.
void DrawSpriteTinted(Sprite *sprite, u8 red, u8 green, u8 blue)
Draw a sprite at its origin in a colour.
void DrawPixel(s32 x, s32 y, u8 shade)
Fill one pixel in a grey.
void DrawSpriteAtOrigin(Sprite *sprite, u16 *palette)
Draw a sprite at its origin, at its size on the screen.
void DrawRectBorder(s32 x, s32 y, s32 width, s32 height, s32 border, u8 transparent, u8 sunken, u8 red, u8 green, u8 blue)
Draw a box with a bevelled border outside its edges, light at the top and the left and dark at the bo...
void LoadTextureFromRom(Sprite *sprite)
Allocate memory for a sprite and decompress it there from the cartridge.
A key of the keyboard of the text tool and its glyph, DecalGlyph of the console.
Definition paintshop.h:103
s32 kernLeft
Definition paintshop.h:109
s32 width
Definition paintshop.h:108
s32 y
Definition paintshop.h:105
u8 character
Definition paintshop.h:106
s32 cellX
Definition paintshop.h:107
s32 kernRight
Definition paintshop.h:110
s32 x
Definition paintshop.h:104
A rectangle of the 640 by 480 screen, ScreenRect of the console.
Definition paintshop.h:74
s32 x
Definition paintshop.h:75
s32 height
Definition paintshop.h:78
s32 y
Definition paintshop.h:76
s32 width
Definition paintshop.h:77
A picture of the paint shop, Sprite of the console.
Definition paintshop.h:82
std::vector< u8 > pixels
Definition paintshop.h:83
s32 drawWidth
Definition paintshop.h:89
std::string asset
Definition paintshop.h:92
s32 width
Definition paintshop.h:85
s32 drawHeight
Definition paintshop.h:90
s32 originX
Definition paintshop.h:87
s32 height
Definition paintshop.h:86
std::unique_ptr< RenderTexture > texture
Definition paintshop.h:93
u8 bitsPerTexel
Definition paintshop.h:84
s32 originY
Definition paintshop.h:88
u8 style
Definition paintshop.h:91
A colour of the palette of the decals and its swatch, PaletteSwatch of the console.
Definition paintshop.h:97
PaintRect rect
Definition paintshop.h:98
std::array< u8, 3 > color
Definition paintshop.h:99
A direction of the console.
Definition paintshop.h:114
f32 x
Definition paintshop.h:115
f32 y
Definition paintshop.h:116
f32 z
Definition paintshop.h:117
void DrawText(const char *text, s32 x, s32 y)
Draw text at a position, aligned as the last alignment set.
void SetTextCustomColors(s32 red, s32 green, s32 blue, s32 red2, s32 green2, s32 blue2)
Set the colors of the top and the bottom of text.
The integer and floating-point types of the console, for headers shared with Windows.
unsigned int u32
Definition ultratypes.h:20
float f32
Definition ultratypes.h:38
unsigned short u16
Definition ultratypes.h:19
int s32
Definition ultratypes.h:25
unsigned char u8
Definition ultratypes.h:18