Changeset 282


Ignore:
Timestamp:
Jan 24, 2011, 10:22:58 PM (10 years ago)
Author:
sam
Message:

Add a Text object for OSD and possibly other effects.

Location:
trunk
Files:
1 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r253 r282  
    88    forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \
    99    profiler.cpp profiler.h input.h input.cpp world.cpp world.h \
    10     sample.cpp sample.h sampler.cpp sampler.h \
     10    sample.cpp sample.h sampler.cpp sampler.h text.cpp text.h \
    1111    \
    1212    sdlinput.cpp sdlinput.h \
  • trunk/src/core.h

    r253 r282  
    3131#include "entity.h"
    3232#include "font.h"
     33#include "sample.h"
     34#include "text.h"
    3335#include "tileset.h"
    34 #include "sample.h"
    3536#include "world.h"
    3637
  • trunk/src/debugfps.cpp

    r259 r282  
    2727
    2828private:
    29     int x, y;
    30     int fontid;
     29    Text *lines[5];
    3130};
    3231
     
    3837  : data(new DebugFpsData())
    3938{
    40     data->fontid = Forge::Register("gfx/font/ascii.png");
    41     data->x = x;
    42     data->y = y;
    43 
    44     drawgroup = DRAWGROUP_HUD;
     39    for (int i = 0; i < 5; i ++)
     40    {
     41        data->lines[i] = new Text(NULL, "gfx/font/ascii.png");
     42        data->lines[i]->SetPos(Int3(x, y + (i ? 8 : 0) + 16 * i, 0));
     43        Ticker::Ref(data->lines[i]);
     44    }
    4545}
    4646
    47 void DebugFps::TickDraw(float deltams)
     47void DebugFps::TickGame(float deltams)
    4848{
    49     Entity::TickDraw(deltams);
     49    Entity::TickGame(deltams);
    5050
    5151    char buf[1024];
    52     Font *font = Forge::GetFont(data->fontid);
    53 
    54     int x = data->x;
    55     int y = data->y;
    5652
    5753    sprintf(buf, "%2.2f fps (%i)",
    5854            1e3f / Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
    5955            Ticker::GetFrameNum());
    60     font->PrintBold(x, y, buf);
     56    data->lines[0]->SetText(buf);
    6157
    6258    sprintf(buf, "Game  % 7.2f % 7.2f",
    6359            Profiler::GetAvg(Profiler::STAT_TICK_GAME),
    6460            Profiler::GetMax(Profiler::STAT_TICK_GAME));
    65     font->PrintBold(x, y + 24, buf);
     61    data->lines[1]->SetText(buf);
    6662
    6763    sprintf(buf, "Draw  % 7.2f % 7.2f",
    6864            Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
    6965            Profiler::GetMax(Profiler::STAT_TICK_DRAW));
    70     font->PrintBold(x, y + 40, buf);
     66    data->lines[2]->SetText(buf);
    7167
    7268    sprintf(buf, "Blit  % 7.2f % 7.2f",
    7369            Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
    7470            Profiler::GetMax(Profiler::STAT_TICK_BLIT));
    75     font->PrintBold(x, y + 56, buf);
     71    data->lines[3]->SetText(buf);
    7672
    7773    sprintf(buf, "Frame % 7.2f % 7.2f",
    7874            Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
    7975            Profiler::GetMax(Profiler::STAT_TICK_FRAME));
    80     font->PrintBold(x, y + 72, buf);
     76    data->lines[4]->SetText(buf);
    8177}
    8278
    8379DebugFps::~DebugFps()
    8480{
    85     Forge::Deregister(data->fontid);
     81    for (int i = 0; i < 5; i ++)
     82        Ticker::Unref(data->lines[i]);
    8683    delete data;
    8784}
  • trunk/src/debugfps.h

    r227 r282  
    2828
    2929protected:
    30     virtual void TickDraw(float deltams);
     30    virtual void TickGame(float deltams);
    3131
    3232private:
  • trunk/src/text.h

    r281 r282  
    1010
    1111//
    12 // The DebugFps class
    13 // ------------------
     12// The Text class
     13// --------------
    1414//
    1515
    16 #if !defined __DH_DEBUGFPS_H__
    17 #define __DH_DEBUGFPS_H__
     16#if !defined __DH_TEXT_H__
     17#define __DH_TEXT_H__
    1818
    1919#include "entity.h"
    2020
    21 class DebugFpsData;
     21class TextData;
    2222
    23 class DebugFps : public Entity
     23class Text : public Entity
    2424{
    2525public:
    26     DebugFps(int x, int y);
    27     virtual ~DebugFps();
     26    Text(char const *text, char const *font);
     27    virtual ~Text();
     28
     29    void SetText(char const *text);
     30    void SetPos(Int3 pos);
    2831
    2932protected:
     
    3134
    3235private:
    33     DebugFpsData *data;
     36    TextData *data;
    3437};
    3538
    36 #endif // __DH_DEBUGFPS_H__
     39#endif // __DH_TEXT_H__
    3740
  • trunk/win32/deushax.vcxproj

    r256 r282  
    3434    <ClInclude Include="..\src\scene.h" />
    3535    <ClInclude Include="..\src\sdlinput.h" />
     36    <ClInclude Include="..\src\text.h" />
    3637    <ClInclude Include="..\src\ticker.h" />
    3738    <ClInclude Include="..\src\tiler.h" />
     
    6263    <ClCompile Include="..\src\scene.cpp" />
    6364    <ClCompile Include="..\src\sdlinput.cpp" />
     65    <ClCompile Include="..\src\text.cpp" />
    6466    <ClCompile Include="..\src\ticker.cpp" />
    6567    <ClCompile Include="..\src\tiler.cpp" />
  • trunk/win32/deushax.vcxproj.filters

    r281 r282  
    5656    </ClInclude>
    5757    <ClInclude Include="..\src\sdlinput.h">
     58      <Filter>lolengine</Filter>
     59    </ClInclude>
     60    <ClInclude Include="..\src\text.h">
    5861      <Filter>lolengine</Filter>
    5962    </ClInclude>
     
    131134      <Filter>lolengine</Filter>
    132135    </ClCompile>
     136    <ClCompile Include="..\src\text.cpp">
     137      <Filter>lolengine</Filter>
     138    </ClCompile>
    133139    <ClCompile Include="..\src\ticker.cpp">
    134140      <Filter>lolengine</Filter>
  • trunk/win32/monsterz.vcxproj

    r279 r282  
    3737    <ClInclude Include="..\src\scene.h" />
    3838    <ClInclude Include="..\src\sdlinput.h" />
     39    <ClInclude Include="..\src\text.h" />
    3940    <ClInclude Include="..\src\ticker.h" />
    4041    <ClInclude Include="..\src\tiler.h" />
     
    6768    <ClCompile Include="..\src\scene.cpp" />
    6869    <ClCompile Include="..\src\sdlinput.cpp" />
     70    <ClCompile Include="..\src\text.cpp" />
    6971    <ClCompile Include="..\src\ticker.cpp" />
    7072    <ClCompile Include="..\src\tiler.cpp" />
  • trunk/win32/monsterz.vcxproj.filters

    r281 r282  
    5656    </ClInclude>
    5757    <ClInclude Include="..\src\sdlinput.h">
     58      <Filter>lolengine</Filter>
     59    </ClInclude>
     60    <ClInclude Include="..\src\text.h">
    5861      <Filter>lolengine</Filter>
    5962    </ClInclude>
     
    134137      <Filter>lolengine</Filter>
    135138    </ClCompile>
     139    <ClCompile Include="..\src\text.cpp">
     140      <Filter>lolengine</Filter>
     141    </ClCompile>
    136142    <ClCompile Include="..\src\ticker.cpp">
    137143      <Filter>lolengine</Filter>
Note: See TracChangeset for help on using the changeset viewer.