Skip to content

Commit

Permalink
Some header cleanup in the file list code
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Jun 2, 2024
1 parent e54ee72 commit 5d5b20d
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 23 deletions.
36 changes: 34 additions & 2 deletions src/common/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "dirlist.h"
#include "GlobalConstants.h"
#include "linfunc.h"
#include "path.h"
#include "RandomNumberGenerator.h"

#include <algorithm>
#include <fstream>
Expand All @@ -16,8 +18,6 @@ extern WorldMusicList* worldmusiclist;

namespace {
const short g_iDefaultMusicCategory[MAXMUSICCATEGORY] {0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0};
}// namespace


struct MapMusicOverride {
std::string mapname;
Expand All @@ -31,6 +31,8 @@ struct WorldMusicOverride {

std::vector<MapMusicOverride> mapmusicoverrides;
std::vector<WorldMusicOverride> worldmusicoverrides;
} // namespace


void UpdateMusicWithOverrides()
{
Expand Down Expand Up @@ -217,6 +219,36 @@ bool SimpleFileList::find(const std::string& name)
return fFound;
}


AnnouncerList::AnnouncerList()
: SimpleFileList(convertPath("sfx/announcer/"), ".txt")
{}

GraphicsList::GraphicsList()
: SimpleDirectoryList(convertPath("gfx/packs/"))
{}

SoundsList::SoundsList()
: SimpleDirectoryList(convertPath("sfx/packs/"))
{}

TourList::TourList()
: SimpleFileList(convertPath("tours/"), ".txt")
{}

WorldList::WorldList()
: SimpleFileList(convertPath("worlds/"), ".txt", true)
{}

BackgroundList::BackgroundList()
: SimpleFileList(convertPath("gfx/packs/Classic/backgrounds/"), ".png")
{}

FiltersList::FiltersList()
: SimpleFileList(convertPath("filters/"), ".txt")
{}


///////////// SkinList ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SkinList::SkinList()
{
Expand Down
27 changes: 13 additions & 14 deletions src/common/FileList.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#ifndef FILELIST_H
#define FILELIST_H

#include "path.h"
#include "RandomNumberGenerator.h"
#pragma once

#include <array>
#include <map>
Expand All @@ -14,6 +10,11 @@
#define MAXWORLDMUSICCATEGORY 9
#define MAXCATEGORYTRACKS 64


// Adds music overrides to the music lists
void UpdateMusicWithOverrides();


//it was kinda a bad idea to have skinlist and announcer list based on this, because both are accessed in different ways (skinlist like an vector and announcer list like a list). grrrr
class SimpleFileList {
public:
Expand Down Expand Up @@ -51,37 +52,37 @@ class SimpleDirectoryList : public SimpleFileList {

class AnnouncerList : public SimpleFileList {
public:
AnnouncerList(): SimpleFileList(convertPath("sfx/announcer/"), ".txt") {}
AnnouncerList();
};

class GraphicsList : public SimpleDirectoryList {
public:
GraphicsList(): SimpleDirectoryList(convertPath("gfx/packs/")) {}
GraphicsList();
};

class SoundsList : public SimpleDirectoryList {
public:
SoundsList(): SimpleDirectoryList(convertPath("sfx/packs/")) {}
SoundsList();
};

class TourList : public SimpleFileList {
public:
TourList() : SimpleFileList(convertPath("tours/"), ".txt") {}
TourList();
};

class WorldList : public SimpleFileList {
public:
WorldList() : SimpleFileList(convertPath("worlds/"), ".txt", true) {}
WorldList();
};

class BackgroundList : public SimpleFileList {
public:
BackgroundList() : SimpleFileList(convertPath("gfx/packs/Classic/backgrounds/"), ".png") {}
BackgroundList();
};

class FiltersList : public SimpleFileList {
public:
FiltersList() : SimpleFileList(convertPath("filters/"), ".txt") {}
FiltersList();
};


Expand Down Expand Up @@ -221,5 +222,3 @@ class WorldMusicList {
std::vector<std::unique_ptr<WorldMusicEntry>> m_entries;
size_t m_currentIndex = 0;
};

#endif // FILELIST_H
1 change: 1 addition & 0 deletions src/common/GameValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "GameMode.h"
#include "GlobalConstants.h"
#include "MapList.h" // req. only by WriteConfig
#include "path.h"
#include "Version.h"
#include "sfx.h"

Expand Down
2 changes: 2 additions & 0 deletions src/common/MapList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "GameValues.h"
#include "linfunc.h"
#include "map.h"
#include "path.h"
#include "RandomNumberGenerator.h"
#include "Version.h"

#include <cstdlib>
Expand Down
1 change: 1 addition & 0 deletions src/common/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Game.h"
#include "GameValues.h"
#include "TilesetManager.h"
#include "path.h"
#include "gfx/Color.h"

extern SkinList *skinlist;
Expand Down
2 changes: 1 addition & 1 deletion src/common/TilesetManager.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "TilesetManager.h"

#include "FileIO.h"
#include "map.h"
#include "path.h"

#include <algorithm>
#include <cassert>
Expand Down
1 change: 1 addition & 0 deletions src/common/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "gfx.h"
#include "map.h"
#include "MapList.h"
#include "path.h"
#include "ResourceManager.h"
#include "TilesetManager.h"

Expand Down
1 change: 1 addition & 0 deletions src/common/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "FileIO.h"
#include "map/MapReader.h"
#include "movingplatform.h"
#include "path.h"
#include "RandomNumberGenerator.h"
#include "ResourceManager.h"
#include "TilesetManager.h"
Expand Down
2 changes: 2 additions & 0 deletions src/smw/GSMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "net.h"
#include "map.h"
#include "MapList.h"
#include "path.h"
#include "RandomNumberGenerator.h"
#include "ResourceManager.h"
#include "Score.h"
#include "gamemodes/BonusHouse.h"
Expand Down
1 change: 1 addition & 0 deletions src/smw/GSSplashScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "GSMenu.h"
#include "GSGameplay.h"
#include "eyecandy.h"
#include "path.h"
#include "ResourceManager.h"

extern SDL_Surface* screen;
Expand Down
5 changes: 1 addition & 4 deletions src/smw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "map.h"
#include "MapList.h"
#include "net.h"
#include "linfunc.h"
#include "path.h"
#include "player.h"
#include "ResourceManager.h"
#include "sfx.h"
Expand Down Expand Up @@ -104,9 +104,6 @@ CGM_Boxes_MiniGame *boxesgamemode = NULL;

short currentgamemode = 0;

//Adds music overrides to the music lists
extern void UpdateMusicWithOverrides();

extern SDL_Joystick **joysticks;
extern short joystickcount;

Expand Down
1 change: 1 addition & 0 deletions src/smw/ui/MI_AnnouncerField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "FileList.h"
#include "input.h"
#include "path.h"
#include "ResourceManager.h"
#include "ui/MI_Image.h"

Expand Down
3 changes: 2 additions & 1 deletion src/smw/ui/MI_NetRoomTeamSelect.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "MI_NetRoomTeamSelect.h"

#include "FileList.h"
#include "GameValues.h"
#include "RandomNumberGenerator.h"
#include "ResourceManager.h"
#include "FileList.h"
#include "ui/MI_Image.h"

extern CGameValues game_values;
Expand Down
1 change: 1 addition & 0 deletions src/smw/ui/MI_TeamSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "gfx.h"
#include "Game.h"
#include "GameValues.h"
#include "RandomNumberGenerator.h"
#include "ResourceManager.h"
#include "FileList.h"
#include "ui/MI_Image.h"
Expand Down
1 change: 1 addition & 0 deletions src/smw/ui/MI_World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "FileList.h"
#include "Game.h"
#include "GameValues.h"
#include "RandomNumberGenerator.h"
#include "ResourceManager.h"
#include "uimenu.h"
#include "world.h"
Expand Down
4 changes: 3 additions & 1 deletion src/smw/world.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "world.h"

#include "FileList.h"
#include "GameValues.h"
#include "path.h"
#include "RandomNumberGenerator.h"
#include "ResourceManager.h"
#include "FileList.h"
#include "Version.h"
#include "WorldTourStop.h"

Expand Down
1 change: 1 addition & 0 deletions src/worldeditor/worldeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "MapList.h"
#include "menu/ModeOptionsMenu.h"
#include "ObjectContainer.h"
#include "path.h"
#include "player.h"
#include "ResourceManager.h"
#include "sfx.h"
Expand Down

0 comments on commit 5d5b20d

Please sign in to comment.