about summary refs log tree commit diff stats
path: root/data/maps/the_sun_temple/doors.txtpb
blob: 7ee2c562da503e1267591bb0b6790843396c2564 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
doors {
  name: "Entrance"
  type: STANDARD
  receivers: "Components/Doors/entry_1"
  panels { room: "Entrance" name: "SUN" }
  location_room: "Entrance"
}
doors {
  name: "Ending"
  type: EVENT
  panels { room: "Temple" name: "EQUINOX" answer: "equinox" }
}
doors {
  name: "Mastery"
  type: EVENT
  panels { room: "Entrance" name: "SUN" answer: "moon" }
  panels { room: "Temple" name: "DELAY" answer: "night" }
  panels { room: "Temple" name: "LAWN" answer: "dusk" }
  panels { room: "Temple" name: "JUMP" answer: "autumn" }
  panels { room: "Temple" name: "HEAVY" answer: "dark" }
  panels { room: "Temple" name: "KNIFE" answer: "death" }
  panels { room: "Temple" name: "ARM" answer: "chill" }
}
ighlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#ifndef RENDERER_H_6A58EC30
#define RENDERER_H_6A58EC30

#include <SDL.h>
#include <SDL_image.h>
#include <stdexcept>
#include <memory>
#include <map>
#include <string>
#include <vector>

class Game;
class Map;
class Sprite;

class sdl_error : public std::logic_error {
public:

  sdl_error() : std::logic_error(SDL_GetError())
  {
  }
};

class img_error : public std::logic_error {
public:

  img_error() : std::logic_error(IMG_GetError())
  {
  }
};

class sdl_wrapper {
public:

  sdl_wrapper()
  {
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
    {
      sdl_error ex;
      SDL_Quit();

    	throw ex;
    }
  }

  ~sdl_wrapper()
  {
    SDL_Quit();
  }
};

class img_wrapper {
public:

  img_wrapper()
  {
    if (IMG_Init(IMG_INIT_PNG) != IMG_INIT_PNG)
    {
      img_error ex;
      IMG_Quit();

      throw ex;
    }
  }

  ~img_wrapper()
  {
    IMG_Quit();
  }
};

class window_deleter {
public:

  void operator()(SDL_Window* ptr)
  {
    SDL_DestroyWindow(ptr);
  }
};

using window_ptr = std::unique_ptr<SDL_Window, window_deleter>;

class renderer_deleter {
public:

  void operator()(SDL_Renderer* ptr)
  {
    SDL_DestroyRenderer(ptr);
  }
};

using renderer_ptr = std::unique_ptr<SDL_Renderer, renderer_deleter>;

class surface_deleter {
public:

  void operator()(SDL_Surface* ptr)
  {
    SDL_FreeSurface(ptr);
  }
};

using surface_ptr = std::unique_ptr<SDL_Surface, surface_deleter>;

class texture_deleter {
public:

  void operator()(SDL_Texture* ptr)
  {
    SDL_DestroyTexture(ptr);
  }
};

using texture_ptr = std::unique_ptr<SDL_Texture, texture_deleter>;

class Renderer {
public:

  Renderer();

  void render(Game& game);

  int loadImageFromFile(std::string filename);

private:

  // Important wrappers
  sdl_wrapper sdl_;
  img_wrapper img_;
  window_ptr win_;
  renderer_ptr ren_;

  // Textures loaded from files
  std::vector<texture_ptr> textures_;
  std::map<std::string, int> filenameToTexId_;

  // Sprite rendering
  void renderSprite(const Sprite& sprite);

  // Map rendering
  texture_ptr renderMapLayer(const Map& map, bool above);

  std::string cachedMapName_;
  std::string cachedTilesetName_;
  texture_ptr tilesetTex_;
  texture_ptr renLowerLayer_;
  texture_ptr renUpperLayer_;
  texture_ptr mapSwapTex_;

  // Text rendering
  struct MessageCache {
    texture_ptr renderedTex;
    std::vector<int> charIndexToWidth;
    std::string line;
    std::string overflow;
  };

  void renderMessageLine(MessageCache& line, const std::string& text, Game& game);

  MessageCache messageLines_[2];
  int speakerHeaderTex_ = -1;
  MessageCache speakerHeaderLine_;
  int advMsgArrowTex_ = -1;
  int choiceArrowTex_ = -1;

  // Debug console
  texture_ptr debugConsoleTex_;
  std::string cachedDebugText_;
  SDL_Rect debugDestRect_;
};

#endif /* end of include guard: RENDERER_H_6A58EC30 */