--- /dev/null
+#include "CapsuleNameMenu.h"
+
+#include "CapsuleMenu.h"
+#include "Resources.h"
+#include "../app/Application.h"
+#include "../app/Input.h"
+#include "../common/Inventory.h"
+#include "../common/Item.h"
+#include "../common/GameConfig.h"
+#include "../common/GameState.h"
+#include "../graphics/Font.h"
+#include "../graphics/Frame.h"
+
+#include <cstring>
+
+using app::Input;
+using common::Capsule;
+using common::Inventory;
+using common::Item;
+using geometry::Vector;
+using graphics::Font;
+using graphics::Frame;
+
+namespace menu {
+
+CapsuleNameMenu::CapsuleNameMenu(CapsuleMenu *parent)
+: parent(parent)
+, cursor(5) {
+ std::strncpy(buffer, GetCapsule().Name(), 6);
+ buffer[5] = '\0';
+}
+
+
+void CapsuleNameMenu::OnEnterState(SDL_Surface *) {
+
+}
+
+void CapsuleNameMenu::OnExitState(SDL_Surface *) {
+
+}
+
+void CapsuleNameMenu::OnResumeState(SDL_Surface *) {
+
+}
+
+void CapsuleNameMenu::OnPauseState(SDL_Surface *) {
+
+}
+
+
+void CapsuleNameMenu::OnResize(int width, int height) {
+
+}
+
+
+void CapsuleNameMenu::HandleEvents(const Input &input) {
+ if (input.JustPressed(Input::START)) {
+ Ctrl().PopState();
+ }
+}
+
+void CapsuleNameMenu::UpdateWorld(float deltaT) {
+
+}
+
+void CapsuleNameMenu::Render(SDL_Surface *screen) {
+ const Font &font(*parent->Res().statusFont);
+ const Vector<int> offset((screen->w - Width()) / 2, (screen->h - Height()) / 2);
+ const Vector<int> nameOffset(
+ 4 * font.CharWidth(),
+ 4 * font.CharHeight() - font.CharHeight() / 8);
+ const Vector<int> alphaOffset(
+ 4 * font.CharWidth(),
+ 7 * font.CharHeight() - font.CharHeight() / 8);
+
+ parent->RenderBackground(screen);
+ RenderName(screen, offset + nameOffset);
+ RenderAlphabet(screen, offset + alphaOffset);
+}
+
+void CapsuleNameMenu::RenderName(SDL_Surface *screen, const Vector<int> &offset) const {
+ const Font &font(*parent->Res().normalFont);
+ const Frame &frame(*parent->Res().statusFrame);
+ const Vector<int> labelOffset(2 * font.CharWidth(), font.CharHeight());
+ const Vector<int> namebgOffset(8 * font.CharWidth(), 0);
+ const Vector<int> nameOffset(13 * font.CharWidth(), font.CharHeight());
+
+ frame.Draw(screen, offset, 8 * font.CharWidth(), 3 * font.CharHeight());
+ font.DrawString(parent->Res().capsuleNameLabel, screen, offset + labelOffset, 5);
+ frame.Draw(screen, offset + namebgOffset, 16 * font.CharWidth(), 3 * font.CharHeight());
+ font.DrawString(buffer, screen, offset + nameOffset, 5);
+}
+
+void CapsuleNameMenu::RenderAlphabet(SDL_Surface *screen, const Vector<int> &offset) const {
+ const Font &font(*parent->Res().normalFont);
+ const Frame &frame(*parent->Res().statusFrame);
+
+ frame.Draw(screen, offset, 24 * font.CharWidth(), 17 * font.CharHeight());
+}
+
+
+int CapsuleNameMenu::Width() const {
+ return parent->Width();
+}
+
+int CapsuleNameMenu::Height() const {
+ return parent->Height();
+}
+
+const Capsule &CapsuleNameMenu::GetCapsule() const {
+ return parent->GetCapsule();
+}
+
+}