Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tizian/Cendric2
Browse files Browse the repository at this point in the history
  • Loading branch information
tizian committed Sep 29, 2015
2 parents b1b9f13 + d42e7af commit 715e0d1
Show file tree
Hide file tree
Showing 27 changed files with 138 additions and 62 deletions.
9 changes: 8 additions & 1 deletion Readme.txt
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
git clone https://github.com/tizian/Cendric2.git
To clone the github directory
git clone https://github.com/tizian/Cendric2.git

for further information about the project, go to
http://cendric.ch

for further information about the code and how to contribute, go to
http://cendric.ch/contribute/code
4 changes: 3 additions & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sound.on:1
# this is the sound volume in percent (0 - 100)
sound.volume:100
# 1 for EN, 2 for DE, 3 for CH
language:3
language:1
# 0 means quickcast off, 1 means quickcast on
quickcast.on:1
# the key input mapping.
Expand Down Expand Up @@ -38,6 +38,7 @@ input.main.key:19,30
input.main.key:20,31
input.main.key:21,32
input.main.key:22,33
input.main.key:23,60
# the alternative key input mapping.
input.alternative.key:1,101
input.alternative.key:2,101
Expand All @@ -61,6 +62,7 @@ input.alternative.key:19,79
input.alternative.key:20,80
input.alternative.key:21,81
input.alternative.key:22,82
input.alternative.key:23,101
# the fps limit for the game. Choose a value between 30 and 100
fps.max:80
# 0 means window mode, 1 means fullscreen mode
Expand Down
2 changes: 2 additions & 0 deletions include/Enums/EnumNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ class EnumNames
return "Quickslot2";
case Key::Up:
return "MoveUp";
case Key::ToggleTooltips:
return "ToggleTooltips";
}
}

Expand Down
1 change: 1 addition & 0 deletions include/Enums/Key.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ enum class Key
FifthSpell,
QuickSlot1,
QuickSlot2,
ToggleTooltips,
MAX
};
1 change: 1 addition & 0 deletions include/GUI/ItemDescriptionWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ItemDescriptionWindow : public Window

void show();
void hide();
bool isVisible() const;

static const float WIDTH;

Expand Down
2 changes: 2 additions & 0 deletions include/Level.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Level
void loadForRenderTexture(Screen* screen);
// loads enemies and level items for the level. must be called after a screen already has a main char
void loadAfterMainChar(Screen* screen);
// updates the level camera
void updateCamera(const sf::Time& frameTime);
// draws the level. Background layers, background tilemap, dynamic tiles
void drawBackground(sf::RenderTarget &target, const sf::RenderStates& states, const sf::Vector2f& center) const;
// draws the level. Foreground tilemap
Expand Down
1 change: 1 addition & 0 deletions include/Screens/MenuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MenuScreen : public Screen

private:
sf::Sprite m_screenSprite;
BitmapText m_versionText;

void setAllButtonsEnabled(bool value) override;

Expand Down
6 changes: 1 addition & 5 deletions include/Screens/SplashScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
#include "MenuScreen.h"
#include "Misc/FireBasket.h"

// TODO: Remove test includes and everything that belongs to it.
#include "GUI/SpellSlot.h"
#include "Structs/SpellBean.h"
#include "Particles/ParticleSystem.h"

class SplashScreen : public Screen
{
public:
Expand All @@ -24,4 +19,5 @@ class SplashScreen : public Screen

private:
sf::Sprite m_screenSprite;
BitmapText m_versionText;
};
5 changes: 4 additions & 1 deletion include/SpeedupPullCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
class SpeedupPullCamera
{
public:
void update(const sf::Time& frameTime);

void setCameraWindowHeight(float height);
void setCameraWindowWidth(float width);
void setFocusCenter(const sf::Vector2f& center);

const sf::Vector2f& getCameraCenter() const;

private:
Expand All @@ -19,4 +19,7 @@ class SpeedupPullCamera
float m_cameraWindowHeight = 0.f;
float m_cameraLeft = 0;
float m_cameraTop = 0;

// the speed the camera window is allowed to move when toggled by a user
const float CAMERA_SPEED_PER_S = 200.f;
};
6 changes: 4 additions & 2 deletions include/Structs/ConfigurationData.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ std::map < Key, sf::Keyboard::Key >(
{ Key::FourthSpell, sf::Keyboard::Num4 },
{ Key::FifthSpell, sf::Keyboard::Num5 },
{ Key::QuickSlot1, sf::Keyboard::Num6 },
{ Key::QuickSlot2, sf::Keyboard::Num7 }
{ Key::QuickSlot2, sf::Keyboard::Num7 },
{ Key::ToggleTooltips, sf::Keyboard::Tab }
});

const struct ConfigurationData DEFAULT_CONFIGURATION =
Expand Down Expand Up @@ -84,7 +85,8 @@ const struct ConfigurationData DEFAULT_CONFIGURATION =
{ Key::FourthSpell, sf::Keyboard::Numpad4 },
{ Key::FifthSpell, sf::Keyboard::Numpad5 },
{ Key::QuickSlot1, sf::Keyboard::Numpad6 },
{ Key::QuickSlot2, sf::Keyboard::Numpad7 }
{ Key::QuickSlot2, sf::Keyboard::Numpad7 },
{ Key::ToggleTooltips, sf::Keyboard::KeyCount }
}),
true,
false,
Expand Down
5 changes: 4 additions & 1 deletion include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ inline float lerp(float t, float v1, float v2) {
return (1.f - t) * v1 + t * v2;
}

// TODO these values should not be const, but loaded from an .ini file.
// versioning
#define CENDRIC_VERSION_NR "0.1.0"

// const canvas size (window can be rescaled though)
#define WINDOW_WIDTH 1280
#define WINDOW_HEIGHT 720

Expand Down
18 changes: 14 additions & 4 deletions res/translations_core.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ Cooldown;Cooldown;Abklingzeit;Abklingziit
CooldownReduction;Cooldown Reduction;Abklingzeitverringerung;Abklingziitverringering
Count;Count;Anzahl;Aazahl
Credits;Credits;Mitwirkende;Erschaffer
CreditsText;"Cendric Font:
CreditsText;"Project Lead:
Isa
Lead Effects and Simulation:
Tizian
too many text on one line yay way to many text this needs to be cropped so hard whatsthisverylongworditdoesn'tfitatallomglookatthisworditssoooooooooooooooooooolong and there are some other words and some more words and to conclude there is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword.";"Cendric Font:
Placeholder Soundeffects for Fireball and Water Splash
Mike Koenig";"Project Lead:
Isa
Lead Effects and Simulation:
Tizian
too many text on one line yay way to many text this needs to be cropped so hard whatsthisverylongworditdoesn'tfitatallomglookatthisworditssoooooooooooooooooooolong and there are some other words and some more words and to conclude there is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword.";"Cendric Font:
Placeholder Soundeffects for Fireball and Water Splash
Mike Koenig";"Project Lead:
Isa
Lead Effects and Simulation:
Tizian
too many text on one line yay way to many text this needs to be cropped so hard whatsthisverylongworditdoesn'tfitatallomglookatthisworditssoooooooooooooooooooolong and there are some other words and some more words and to conclude there is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword."
Placeholder Soundeffects for Fireball and Water Splash
Mike Koenig"
Critical;Critical;Kritisch;Kritisch
CriticalHitChance;Critical Hit Chance;Chance auf kritische Treffer;Chance uf kritischi Treffer
Damage;Damage;Schaden;Schade
Expand Down Expand Up @@ -166,6 +175,7 @@ StartGame;Start Game;Spiel starten;Spiel starte
Strength;Strength;St�rke;St�rchi
SwissGerman;Swiss German;Schweizerdeutsch;Schwiizerd��tsch
ThirdSpell;3. Spell;3. Zauber;3. Zauber
ToggleTooltips;Toggle Tooltips;Tooltips anzeigen/verbergen;Tooltips zeige/verstecke
Twilight;Twilight;Zwielicht;Zwieliecht
Type;Type;Typ;Typ
Unknown;Unknown;Unbekannt;Unbekannt
Expand Down
1 change: 1 addition & 0 deletions src/DynamicTiles/ChestTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void ChestTile::update(const sf::Time& frameTime)
sf::Vector2f pos(getBoundingBox()->left + getBoundingBox()->width, getBoundingBox()->top - m_lootWindow->getSize().y + 10.f);
m_lootWindow->setPosition(pos);
}
m_showLootWindow = m_showLootWindow || g_inputController->isKeyActive(Key::ToggleTooltips);
}

void ChestTile::setObjectID(int id)
Expand Down
1 change: 1 addition & 0 deletions src/Enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void Enemy::update(const sf::Time& frameTime)
sf::Vector2f pos(getBoundingBox()->left + getBoundingBox()->width, getBoundingBox()->top - m_lootWindow->getSize().y + 10.f);
m_lootWindow->setPosition(pos);
}
m_showLootWindow = m_showLootWindow || g_inputController->isKeyActive(Key::ToggleTooltips);
}

void Enemy::updateHpBar()
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void Inventory::showDocument(const Item& item)
sf::Vector2f pos = sf::Vector2f(
m_window->getPosition().x + MARGIN + m_window->getSize().x,
m_window->getPosition().y);
if (m_descriptionWindow != nullptr)
if (m_descriptionWindow->isVisible())
{
pos.x += ItemDescriptionWindow::WIDTH + MARGIN;
}
Expand Down
5 changes: 5 additions & 0 deletions src/GUI/ItemDescriptionWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,9 @@ void ItemDescriptionWindow::hide()
m_isVisible = false;
}

bool ItemDescriptionWindow::isVisible() const
{
return m_isVisible;
}


3 changes: 2 additions & 1 deletion src/InputController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ void InputController::init()
{ Key::FourthSpell, false },
{ Key::FifthSpell, false },
{ Key::QuickSlot1, false },
{ Key::QuickSlot2, false }
{ Key::QuickSlot2, false },
{ Key::ToggleTooltips, false }
});
m_keyJustPressedMap = m_keyActiveMap;

Expand Down
17 changes: 6 additions & 11 deletions src/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ void Level::loadForRenderTexture(Screen* screen)
loader.loadLights(m_levelData, screen);
m_dynamicTiles = screen->getObjects(GameObjectType::_DynamicTile);
}

void Level::updateCamera(const sf::Time& frameTime)
{
m_camera->update(frameTime);
}

void Level::drawBackground(sf::RenderTarget &target, const sf::RenderStates& states, const sf::Vector2f& center) const
{
sf::View view;
Expand Down Expand Up @@ -95,22 +101,11 @@ void Level::drawBackground(sf::RenderTarget &target, const sf::RenderStates& sta
view.setCenter(camCenterX, camCenterY);
target.setView(view);
m_backgroundTileMap.draw(target, states);

// dynamic tiles
for (auto &it : (*m_dynamicTiles))
{
it->render(target);
}
}

void Level::drawForeground(sf::RenderTarget &target, const sf::RenderStates& states, const sf::Vector2f& center) const
{
m_foregroundTileMap.draw(target, states);
// dynamic tiles
for (auto &it : (*m_dynamicTiles))
{
it->renderAfterForeground(target);
}
}

const sf::FloatRect& Level::getLevelRect() const
Expand Down
3 changes: 2 additions & 1 deletion src/LevelItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void LevelItem::render(sf::RenderTarget &renderTarget)
void LevelItem::renderAfterForeground(sf::RenderTarget& renderTarget)
{
GameObject::renderAfterForeground(renderTarget);
if (m_tooltipTime > sf::Time::Zero)
bool showTooltip = g_inputController->isKeyActive(Key::ToggleTooltips);
if (showTooltip || m_tooltipTime > sf::Time::Zero)
{
renderTarget.draw(m_tooltipText);
}
Expand Down
1 change: 1 addition & 0 deletions src/LightObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void LightObject::init()
setBoundingBox(sf::FloatRect(0.f, 0.f, 2.f * m_bean.radius.x, 2.f * m_bean.radius.y));

setPosition(m_bean.center);
setDebugBoundingBox(sf::Color(255, 255, 0, 100));
}

GameObjectType LightObject::getConfiguredType() const
Expand Down
3 changes: 2 additions & 1 deletion src/NPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void NPC::onInteractKey()
void NPC::renderAfterForeground(sf::RenderTarget &renderTarget)
{
GameObject::renderAfterForeground(renderTarget);
if (m_tooltipTime > sf::Time::Zero)
bool showTooltip = g_inputController->isKeyActive(Key::ToggleTooltips);
if (showTooltip || m_tooltipTime > sf::Time::Zero)
{
renderTarget.draw(m_tooltipText);
}
Expand Down
16 changes: 6 additions & 10 deletions src/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@

using namespace std;

#define VIEW_MARGIN 50;
#define VIEW_MARGIN 50.f;

inline bool isInsideView(const sf::View& targetView, const sf::FloatRect& boundingBox)
{
sf::IntRect view(static_cast<int>(targetView.getCenter().x - targetView.getSize().x / 2),
static_cast<int>(targetView.getCenter().y - targetView.getSize().y / 2),
static_cast<int>(targetView.getSize().x),
static_cast<int>(targetView.getSize().y));
sf::FloatRect view(targetView.getCenter().x - targetView.getSize().x / 2.f,
targetView.getCenter().y - targetView.getSize().y / 2.f,
targetView.getSize().x,
targetView.getSize().y);

view.left -= VIEW_MARGIN;
view.top -= VIEW_MARGIN;
view.width += 2 * VIEW_MARGIN;
view.height += 2 * VIEW_MARGIN;
if (view.contains(static_cast<int>(boundingBox.left), static_cast<int>(boundingBox.top)))
return true;
if (view.contains(static_cast<int>(boundingBox.left + static_cast<int>(boundingBox.width)), static_cast<int>(boundingBox.top + boundingBox.height)))
return true;
return false;
return view.intersects(boundingBox);
}

Screen::Screen(CharacterCore* core)
Expand Down
12 changes: 6 additions & 6 deletions src/Screens/KeyBindingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Screen* KeyBindingsScreen::update(const sf::Time& frameTime)
g_resourceManager->getConfiguration().mainKeyMap = m_selectedKeys;
ConfigurationWriter writer;
writer.saveToFile(g_resourceManager->getConfiguration());
setTooltipText(g_textProvider->getText("ConfigurationSaved"), sf::Color::White, true);
setTooltipText(g_textProvider->getText("ConfigurationSaved"), sf::Color::Green, true);
}

for (auto& it : m_keyButtons)
Expand Down Expand Up @@ -95,7 +95,7 @@ void KeyBindingsScreen::execOnEnter(const Screen *previousScreen)
// title
m_title = new BitmapText(g_textProvider->getText("KeyBindings"));
m_title->setCharacterSize(50);
m_title->setPosition(sf::Vector2f((WINDOW_WIDTH - m_title->getLocalBounds().width) / 2.f, 50.f));
m_title->setPosition(sf::Vector2f((WINDOW_WIDTH - m_title->getLocalBounds().width) / 2.f, 30.f));

m_selectedKeys = g_resourceManager->getConfiguration().mainKeyMap;

Expand All @@ -104,7 +104,7 @@ void KeyBindingsScreen::execOnEnter(const Screen *previousScreen)
const float buttonWidth = 200.f;
const float buttonHeight = 50.f;
const float marginX = 60.f;
const float marginY = WINDOW_HEIGHT - 100.f;
const float marginY = WINDOW_HEIGHT - 80.f;
const float buttonSpaceWidth = WINDOW_WIDTH - 2 * marginX;
const float buttonSpacing = (buttonSpaceWidth - 4 * buttonWidth) / 3.f;

Expand Down Expand Up @@ -151,9 +151,9 @@ void KeyBindingsScreen::reload()
}
m_keyButtons.clear();

float distFromTop = 150.f;
float distFromTop = 120.f;
float distFromLeft = 150.f;
const float maxDistFromTop = WINDOW_HEIGHT - 150.f;
const float maxDistFromTop = WINDOW_HEIGHT - 130.f;

// keyboard mappings
for (auto& it : m_selectedKeys)
Expand All @@ -178,7 +178,7 @@ void KeyBindingsScreen::reload()
distFromTop = distFromTop + 40;
if (distFromTop > maxDistFromTop)
{
distFromTop = 150.f;
distFromTop = 120.f;
distFromLeft = WINDOW_WIDTH / 2.f + 75.f;
}
}
Expand Down
Loading

0 comments on commit 715e0d1

Please sign in to comment.