10 #include <SFML/Window.hpp>
11 #include <SFML/Graphics.hpp>
12 #include <SFML/System.hpp>
13 #include <SFML/OpenGL.hpp>
14 #include "../jugimap/jugimap.h"
34 opened = fis.open(fileName);
46 bool IsOpen()
override {
return opened;}
47 int Pos()
override {
return fis.tell();}
48 void Seek(
int _pos)
override {fis.seek(_pos);}
49 int Size()
override {
return fis.getSize();}
56 fis.read(reinterpret_cast<char*>(&value), 1);
63 fis.read(reinterpret_cast<char*>(&value), 4);
70 fis.read(reinterpret_cast<char*>(&value), 4);
79 sf::FileInputStream fis;
99 virtual void Init()
override;
105 sf::Texture *sfTexture =
nullptr;
135 sf::Sprite *sfSprite =
nullptr;
136 sf::BlendMode sfBlend;
139 sf::Shader *shader =
nullptr;
141 int drawChangeFlags = 0;
143 void ManageShaders_OverlayColor();
157 static Vec2f posOffset;
174 sf::Text* sfText =
nullptr;
182 class ShaderSFML_ColorOverlay_SimpleMultiply;
183 class ShaderSFML_ColorOverlay_Normal;
184 class ShaderSFML_ColorOverlay_Multiply;
185 class ShaderSFML_ColorOverlay_LinearDodge;
186 class ShaderSFML_ColorOverlay_Color;
188 class FragmentShaderSFML_ColorOverlay
191 friend class ShaderSFML_ColorOverlay_SimpleMultiply;
192 friend class ShaderSFML_ColorOverlay_Normal;
193 friend class ShaderSFML_ColorOverlay_Multiply;
194 friend class ShaderSFML_ColorOverlay_LinearDodge;
195 friend class ShaderSFML_ColorOverlay_Color;
198 virtual ~FragmentShaderSFML_ColorOverlay(){
if(shader)
delete shader; }
199 void Load(
const std::string &_filePath);
201 sf::Shader *GetShader(){
return shader; }
202 ColorRGBA GetColorRGBA(){
return colorRGBA; }
203 void SetColorRGBA(ColorRGBA _colorRGBA){ colorRGBA = _colorRGBA; }
204 const std::string &GetColorRGBAname(){
return colorRGBAname; }
208 sf::Shader *shader =
nullptr;
211 ColorRGBA colorRGBA{255, 255, 255, 128};
212 std::string colorRGBAname =
"overlayColor";
216 class ShaderSFML_ColorOverlay_SimpleMultiply :
public FragmentShaderSFML_ColorOverlay
220 class ShaderSFML_ColorOverlay_Normal :
public FragmentShaderSFML_ColorOverlay
224 class ShaderSFML_ColorOverlay_Multiply :
public FragmentShaderSFML_ColorOverlay
228 class ShaderSFML_ColorOverlay_LinearDodge :
public FragmentShaderSFML_ColorOverlay
232 class ShaderSFML_ColorOverlay_Color :
public FragmentShaderSFML_ColorOverlay
238 extern ShaderSFML_ColorOverlay_SimpleMultiply ColorOverlay_SimpleMultiply;
239 extern ShaderSFML_ColorOverlay_Normal ColorOverlay_Normal;
240 extern ShaderSFML_ColorOverlay_Multiply ColorOverlay_Multiply;
241 extern ShaderSFML_ColorOverlay_LinearDodge ColorOverlay_LinearDodge;
242 extern ShaderSFML_ColorOverlay_Color ColorOverlay_Color;
244 void LoadJugimapShaders();
257 static std::wstring_convert<std::codecvt_utf8<sf::Uint32>, sf::Uint32> conv;
262 virtual int GetPixelWidth(
const std::string &s)
override;
263 virtual int GetPixelHeight(
const std::string &s)
override;
264 virtual Vec2f GetPixelSize(
const std::string &s)
override;
270 sf::Font* sfFont =
nullptr;
271 sf::Text* sfText =
nullptr;
332 sf::Color sfOutlineColor;
347 MapSFML(
int _zOrderStart) :
Map(_zOrderStart) {}
364 void PreUpdate()
override;
372 class EngineAppSFML :
public EngineApp
376 EngineAppSFML(App *_app) : EngineApp(_app){}
378 void SetSystemMouseCursorVisible(
bool _visible)
override;
414 struct KeyboardConversionTable
417 KeyboardConversionTable();
419 std::vector<jugimap::KeyCode>table;
424 void ProcessEvents(sf::Event &event);
474 return new FontSFML(_relativeFilePath, _size, _fontKind);
486 extern sf::RenderTarget *CurrentRenderTarget;
487 extern sf::Window *CurrentWindow;
489 extern int countSpriteDrawCalls;
490 extern int countDrawnSprites;
491 extern int countDrawnFrames;
virtual void EllipseOutline(jugimap::Vec2f c, jugimap::Vec2f r) override
Draw the outline of an ellipse defined by the given center point c and radius r.
Definition: jmSFML.cpp:746
void Seek(int _pos) override
Set the current reading position of the stream.
Definition: jmSFML.h:48
bool IsOpen() override
Returns true if the stream of this object is open for reading; if not it returns false.
Definition: jmSFML.h:46
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSFML.cpp:98
sf::Text * GetSFText()
Returns the SFML text object.
Definition: jmSFML.h:170
virtual void DrawEngineSprite() override
Draw the engine sprite.
Definition: jmSFML.cpp:502
virtual void UpdateEngineObjects() override
Update the engine sprite.
Definition: jmSFML.cpp:157
Extended TextSprite class for SFML.
Definition: jmSFML.h:153
Extended Drawer class for SFML.
Definition: jmSFML.h:321
virtual StandardSprite * NewStandardSprite() override
Returns a new standard sprite object.
Definition: jmSFML.h:459
Color in RGBA color space - integer variant.
Definition: jmColor.h:15
virtual void Init() override
Initialize this GraphicFile.
Definition: jmSFML.cpp:43
The EngineScene class defines engine specific scene properties.
Definition: jmScene.h:109
The App is the base class of the application.
Definition: jmApp.h:22
virtual TextSprite * NewTextSprite() override
Returns a new standard sprite object.
Definition: jmSFML.h:464
Extended Font class for SFML.
Definition: jmSFML.h:254
int Size() override
Returns the size of the stream.
Definition: jmSFML.h:49
The Scene class is the base class for the application scenes.
Definition: jmScene.h:23
virtual void Dot(jugimap::Vec2f p) override
Draw a dot at the given position p.
Definition: jmSFML.cpp:768
virtual Map * NewMap(int _zOrderStart) override
Returns a new map object.
Definition: jmSFML.h:458
virtual bool IsEngineSpriteInitialized() override
Returns true if the engine sprite of this sprite has been initialized; otherwise returns false.
Definition: jmSFML.h:165
The GraphicItem class defines the equivalent object from JugiMap Editor.
Definition: jmSourceGraphics.h:34
The EngineApp class defines engine specific application properties.
Definition: jmApp.h:115
int ReadInt() override
Read and returns the integer number (4 bytes).
Definition: jmSFML.h:60
The base abstract class for reading binary streams.
Definition: jmStreams.h:33
Map()
Constructor.
Definition: jmMap.h:34
The StandardSprite class defines the sprite from JugiMap Editor.
Definition: jmSprites.h:787
virtual EngineScene * NewEngineScene(Scene *_scene) override
Returns a new map object.
Definition: jmSFML.h:469
int Pos() override
Returns the current reading position of the stream.
Definition: jmSFML.h:47
Extended GraphicFile class for SFML.
Definition: jmSFML.h:91
sf::Sprite * GetSFSprite()
Returns the SFML sprite object.
Definition: jmSFML.h:131
FontKind
The kinds of font.
Definition: jmGlobal.h:124
std::string ReadString() override
Read and returns the string. The length of string is written as the integer at the start.
Definition: jmSFML.cpp:18
virtual void DrawEngineSprite() override
Draw the engine sprite.
Definition: jmSFML.cpp:243
float ReadFloat() override
Read and returns the float number (4 bytes).
Definition: jmSFML.h:67
The GraphicFile class defines the equivalent object from JugiMap Editor.
Definition: jmSourceGraphics.h:148
virtual void RectangleOutline(const jugimap::Rectf &rect) override
Draw the outline of the given rectangle rect.
Definition: jmSFML.cpp:731
virtual Font * NewFont(const std::string &_relativeFilePath, int _size, FontKind _fontKind) override
Returns a new text object.
Definition: jmSFML.h:472
sf::Font * GetSFFont()
Returns the SFML font object.
Definition: jmSFML.h:267
The Drawer is the base drawer class.
Definition: jmDrawing.h:20
virtual EngineApp * NewEngineApp(App *_app) override
Returns a new map object.
Definition: jmSFML.h:470
static bool textureSmoothFilter
Set true for smooth texture filtering; set false for no filtering.
Definition: jmSFML.h:94
void DrawEngineObjects() override
Draw the engine map objects.
Definition: jmSFML.cpp:786
virtual GraphicFile * NewFile() override
Returns a new graphic file object.
Definition: jmSFML.h:457
virtual void Line(jugimap::Vec2f p1, jugimap::Vec2f p2) override
Draw a line from the given position p1 to p2.
Definition: jmSFML.cpp:720
The Font class defines fonts used in TextSprite objects.
Definition: jmFont.h:16
const sf::Texture * GetSFTexture() const
Returns the SFML texture object.
Definition: jmSFML.h:102
The ObjectFactory is the base class for engine specific object factories.
Definition: jmObjectFactory.h:48
Extended StandardSprite class for SFML.
Definition: jmSFML.h:114
Extended BinaryStreamReader class for SFML.
Definition: jmSFML.h:24
virtual void SetOutlineColor(ColorRGBA _outlineColor) override
Set outline color to the given *_outlineColor*.
Definition: jmSFML.cpp:714
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSFML.cpp:388
Extended Map class for SFML.
Definition: jmSFML.h:342
virtual void UpdateEngineObjects() override
Update the engine sprite.
Definition: jmSFML.cpp:417
virtual void CaptureForLerpDrawing() override
Capture the sprite properties, usually the position only, required for the lerp drawing.
Definition: jmSFML.cpp:236
BinaryFileStreamReaderSFML(const std::string &fileName)
Constructor.
Definition: jmSFML.h:32
The TextSprite class defines the text sprite from JugiMap Editor.
Definition: jmSprites.h:889
virtual void SetActiveImage(GraphicItem *_image) override
Set the active image to the given *_image*.
Definition: jmSFML.cpp:128
unsigned char ReadByte() override
Read and returns the byte number.
Definition: jmSFML.h:53
The Map class defines the map element from JugiMap Editor.
Definition: jmMap.h:26
Extended ObjectFactory class for SFML.
Definition: jmSFML.h:451
void Close() override
Close the stream.
Definition: jmSFML.h:50
virtual Drawer * NewDrawer() override
Returns a new drawer object.
Definition: jmSFML.h:477