Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the 'make install' works #92

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUBDIRS = src
SUBDIRS = src graphics fonts songs
12 changes: 11 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ AC_CHECK_HEADERS([string string.h iostream algorithm locale vector sstream queue

PKG_CHECK_MODULES(SFML, sfml-graphics)

# Flags
datdir=$datadir/$PACKAGE
AC_SUBST(datdir)

CXXFLAGS="$CXXFLAGS -std=c++11"
CXXFLAGS="$CXXFLAGS -DDATADIR=\\\"$datdir\\\""

# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
Expand All @@ -36,5 +41,10 @@ AC_TYPE_UINT32_T
# Checks for library functions.
AC_CHECK_FUNCS([gettimeofday])

AC_CONFIG_FILES([Makefile src/Makefile])
AC_CONFIG_FILES([
Makefile
src/Makefile
graphics/Makefile
fonts/Makefile
songs/Makefile])
AC_OUTPUT
7 changes: 7 additions & 0 deletions fonts/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
EXTRA_DIST = FaunaOne-Regular.ttf

install-data-local:
$(mkinstalldirs) $(DESTDOR)$(datdir)/fonts
@for file in $(EXTRA_DIST); do\
$(INSTALL_DATA) $$file $(DESTDIR)$(datdir)/fonts/$$file;\
done
9 changes: 9 additions & 0 deletions graphics/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
EXTRA_DIST = button.png button2line.png InterfaceButtons.tga \
keyboard_top_separator.png longbutton.png star.png thumb_down.png \
title_Logo.png trackbox.png

install-data-local:
$(mkinstalldirs) $(DESTDOR)$(datdir)/graphics
@for file in $(EXTRA_DIST); do\
$(INSTALL_DATA) $$file $(DESTDIR)$(datdir)/graphics/$$file;\
done
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions songs/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
EXTRA_DIST = Aria-Notebook_AM_Bach.mid Fur_Elise-Beethoven.mid \
Minuet_in_F-Leopold_Mozart.mid Rondino-Rameau.mid Sonatina_in_C-Latour.mid \
Clementi_Opus_36_no_1_First_Movement.mid Minuet_in_G-JS_Bach.mid \
Russian_Folksong-Beethoven.mid


install-data-local:
$(mkinstalldirs) $(DESTDOR)$(datdir)/songs
@for file in $(EXTRA_DIST); do\
$(INSTALL_DATA) $$file $(DESTDIR)$(datdir)/songs/$$file;\
done
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ linthesia_SOURCES = main.cpp \
screens/one_player_screen/black_note_to_play.cpp \
screens/file_select_screen/file_select_screen.cpp \
screens/select_track_screen/track_box.cpp \
screens/select_track_screen/select_track_screen.cpp
screens/select_track_screen/select_track_screen.cpp \
utilities/util.c

linthesia_DEPENDENCIES = libmidi.la

Expand Down
8 changes: 5 additions & 3 deletions src/assets/path.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef LINTHESIA_ASSET_PATH_H
#define LINTHESIA_ASSET_PATH_H

#define GRAPHICS_DIR "../graphics/"
#define FONTS_DIR "../fonts/"
#define DEFAULT_FONT FONTS_DIR "FaunaOne-Regular.ttf"
#define GRAPHICS_DIR DATADIR "/graphics/"
#define LOCAL_GRAPHICS_DIR "../graphics/"
#define FONTS_DIR DATADIR "/fonts/"
#define LOCAL_FONTS_DIR "../fonts/"
#define DEFAULT_FONT "FaunaOne-Regular.ttf"

#endif
27 changes: 24 additions & 3 deletions src/buttons/long_one_line_button.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <iostream>
#include <algorithm>

#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>

#include "utilities/util.h"
#include "assets/path.h"
#include "long_one_line_button.h"

Expand All @@ -19,7 +21,18 @@ sf::Font LongOneLineButton::font = sf::Font();
*/
void LongOneLineButton::init() {

const std::string BUTTON = GRAPHICS_DIR "longbutton.png";
std::string actual_graphics_dir_path;
std::string actual_fonts_dir_path;

if (dirExists(GRAPHICS_DIR))
{
actual_graphics_dir_path = GRAPHICS_DIR;
}
else
{
actual_graphics_dir_path = LOCAL_GRAPHICS_DIR;
}
const std::string BUTTON = actual_graphics_dir_path + "longbutton.png";
if (!texture.loadFromFile(BUTTON)) {
std::cerr
<< "Can't load "
Expand All @@ -29,10 +42,18 @@ void LongOneLineButton::init() {
}
texture.setSmooth(true);

if (!font.loadFromFile(DEFAULT_FONT)) {
if (dirExists(FONTS_DIR))
{
actual_fonts_dir_path = FONTS_DIR;
}
else
{
actual_fonts_dir_path = LOCAL_FONTS_DIR;
}
if (!font.loadFromFile(actual_fonts_dir_path + DEFAULT_FONT)) {
std::cerr
<< "Can't load "
<< DEFAULT_FONT
<< actual_fonts_dir_path + DEFAULT_FONT
<< std::endl
;
}
Expand Down
26 changes: 23 additions & 3 deletions src/buttons/short_one_line_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>

#include "utilities/util.h"
#include "assets/path.h"
#include "short_one_line_button.h"

Expand All @@ -18,7 +19,18 @@ sf::Font ShortOneLineButton::font = sf::Font();
*
*/
void ShortOneLineButton::init() {
const std::string BUTTON = GRAPHICS_DIR "button.png";
std::string actual_graphics_dir_path;
std::string actual_fonts_dir_path;

if (dirExists(GRAPHICS_DIR))
{
actual_graphics_dir_path = GRAPHICS_DIR;
}
else
{
actual_graphics_dir_path = LOCAL_GRAPHICS_DIR;
}
const std::string BUTTON = actual_graphics_dir_path + "button.png";
if (!texture.loadFromFile(BUTTON)) {
std::cerr
<< "Can't load "
Expand All @@ -28,10 +40,18 @@ void ShortOneLineButton::init() {
}
texture.setSmooth(true);

if (!font.loadFromFile(DEFAULT_FONT)) {
if (dirExists(FONTS_DIR))
{
actual_fonts_dir_path = FONTS_DIR;
}
else
{
actual_fonts_dir_path = LOCAL_FONTS_DIR;
}
if (!font.loadFromFile(actual_fonts_dir_path + DEFAULT_FONT)) {
std::cerr
<< "Can't load "
<< DEFAULT_FONT
<< actual_fonts_dir_path + DEFAULT_FONT
<< std::endl
;
}
Expand Down
27 changes: 24 additions & 3 deletions src/buttons/two_lines_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>

#include "utilities/util.h"
#include "assets/path.h"
#include "two_lines_button.h"

Expand All @@ -25,21 +26,41 @@ TwoLinesButton::TwoLinesButton(
const unsigned INTER_LINE_SPACE = 15;
currentState = ButtonStates::NORMAL;

const std::string BUTTON = GRAPHICS_DIR "button2line.png";
std::string actual_graphics_dir_path;
std::string actual_fonts_dir_path;

if (dirExists(GRAPHICS_DIR))
{
actual_graphics_dir_path = GRAPHICS_DIR;
}
else
{
actual_graphics_dir_path = LOCAL_GRAPHICS_DIR;
}
const std::string BUTTON = actual_graphics_dir_path + "button2line.png";
if (!texture.loadFromFile(BUTTON)) {
std::cerr
<< "Can't load "
<< BUTTON
<< std::endl
;
}

texture.setSmooth(true);
sprite.setTexture(texture);

if (!font.loadFromFile(DEFAULT_FONT)) {
if (dirExists(FONTS_DIR))
{
actual_fonts_dir_path = FONTS_DIR;
}
else
{
actual_fonts_dir_path = LOCAL_FONTS_DIR;
}
if (!font.loadFromFile(actual_fonts_dir_path + DEFAULT_FONT)) {
std::cerr
<< "Can't load "
<< DEFAULT_FONT
<< actual_fonts_dir_path + DEFAULT_FONT
<< std::endl
;
}
Expand Down
14 changes: 13 additions & 1 deletion src/icons/icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>

#include "utilities/util.h"
#include "assets/path.h"
#include "icon.h"

Expand All @@ -17,7 +18,18 @@ sf::Texture Icon::iconsTexture = sf::Texture();
*
*/
void Icon::init() {
const std::string INTERFACE_BUTTONS = GRAPHICS_DIR "InterfaceButtons.tga";
std::string actual_graphics_dir_path;
std::string actual_fonts_dir_path;

if (dirExists(GRAPHICS_DIR))
{
actual_graphics_dir_path = GRAPHICS_DIR;
}
else
{
actual_graphics_dir_path = LOCAL_GRAPHICS_DIR;
}
const std::string INTERFACE_BUTTONS = actual_graphics_dir_path + "InterfaceButtons.tga";
if (!iconsTexture.loadFromFile(INTERFACE_BUTTONS)) {
std::cerr
<< "Can't load "
Expand Down
17 changes: 13 additions & 4 deletions src/keyboard/trail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>

#include "utilities/util.h"
#include "assets/path.h"
#include "trail.h"

Expand All @@ -11,17 +12,25 @@ namespace linthesia {
*
*/
KeyboardTrail::KeyboardTrail() {
const std::string TOP_SEPARATOR =
GRAPHICS_DIR
"keyboard_top_separator.png"
;
std::string actual_graphics_dir_path;

if (dirExists(GRAPHICS_DIR))
{
actual_graphics_dir_path = GRAPHICS_DIR;
}
else
{
actual_graphics_dir_path = LOCAL_GRAPHICS_DIR;
}
const std::string TOP_SEPARATOR = actual_graphics_dir_path + "keyboard_top_separator.png";
if (!texture.loadFromFile(TOP_SEPARATOR)) {
std::cerr
<< "Can't load "
<< TOP_SEPARATOR
<< std::endl
;
}

texture.setSmooth(true);
texture.setRepeated(true);
sprite.setTexture(texture);
Expand Down
18 changes: 16 additions & 2 deletions src/screens/file_select_screen/file_select_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <algorithm>

#include "utilities/tinydir.h"
#include "utilities/util.h"
#include "file_select_screen.h"

#include "context/context.h"
Expand All @@ -16,7 +17,9 @@ const ScreenIndex FileSelectScreen::INDEX = "file_select_screen";
/**
*
*/
const static std::string MIDI_DIR_PATH("../songs/");
const static std::string MIDI_DIR_PATH(DATADIR"/songs/");
const static std::string LOCAL_MIDI_DIR_PATH("../songs/");


/**
*
Expand Down Expand Up @@ -87,9 +90,20 @@ ScreenIndex FileSelectScreen::run(
sf::Event event;

// we initalize the file selector list
midiFileNames = get_midi_files(MIDI_DIR_PATH);
std::string actual_midi_dir_path;
if (dirExists(MIDI_DIR_PATH.c_str()))
{
actual_midi_dir_path = MIDI_DIR_PATH;
}
else
{
actual_midi_dir_path = LOCAL_MIDI_DIR_PATH;
}

midiFileNames = get_midi_files(actual_midi_dir_path);
fileButtons.clear();
for (auto fileName : midiFileNames) {
std::replace( fileName.begin(), fileName.end(), '_', ' '); // replace all '_' to ' '
fileButtons.push_back(LongOneLineButton(fileName));
}
updateIterators(app);
Expand Down
12 changes: 11 additions & 1 deletion src/screens/main_screen/main_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "screens/file_select_screen/file_select_screen.h"
#include "screens/select_track_screen/select_track_screen.h"

#include "utilities/util.h"
#include "assets/path.h"
#include "context/context.h"

Expand Down Expand Up @@ -34,7 +35,16 @@ MainScreen::MainScreen() :
selectTrackButton("play"),
chooseSongButton("song:", "no song selected yet")
{
const std::string LOGO = GRAPHICS_DIR "title_Logo.png";
std::string actual_graphics_dir_path;
if (dirExists(GRAPHICS_DIR))
{
actual_graphics_dir_path = GRAPHICS_DIR;
}
else
{
actual_graphics_dir_path = LOCAL_GRAPHICS_DIR;
}
const std::string LOGO = actual_graphics_dir_path + "title_Logo.png";
if (!logoTexture.loadFromFile(LOGO)) {
std::cerr
<< "Can't load "
Expand Down
Loading