• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › Development Discussion v
« Previous 1 ... 14 15 16 17 18 ... 116 Next »

Dolphin Code: GetTextureDirectory - HiresTextures.cpp
View New Posts | View Today's Posts

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
Dolphin Code: GetTextureDirectory - HiresTextures.cpp
11-09-2018, 07:45 PM (This post was last modified: 11-10-2018, 07:31 PM by Admentus.)
#1
Admentus Offline
Nothing but perfection for gaming
*******
Posts: 1,967
Threads: 25
Joined: May 2015
Soo... I am kinda new with writing C++ code and stuff. But I wanted it to give it a try anyway.

A while ago I mentioned this feature request: https://forums.dolphin-emu.org/Thread-feature-request-custom-textures-folder-for-multiple-games.

As proof of concept, I managed to draft up the following code. It is probably horrible. I kinda managed to adjust the GetTextureDirectory method within the HiresTextures.cpp code file.

The idea is that you can place a .txt file naming it with a Game ID of the game you want to load. The text file should contain a single line of text containing the Game ID the loaded game should refer to for loading the texture pack. That's basically it. The goal is to get rid of symbolic links... I hope?

I would love that take this further on GitHub, Pull Requests and such for example. Except... I don't have any idea how to idea how to do that. So I leave it in this thread for now.

UPDATED

Code:
std::string HiresTexture::GetTextureDirectory(const std::string& game_id)
{
  const std::string texture_directory = File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id;

  // If there's no directory with the region-specific ID, look for a 3-character region-free one
  if (!File::Exists(texture_directory))
  {
    // First try looking if a text file exists with either the region-specific ID or 3-character
    // region-free ID and check if it contains a referral to texture pack directory
    if (File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id + ".txt") ||
        File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id.substr(0, 3) + ".txt"))
    {
      std::string texture_text_file = File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id + ".txt";
      if (File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id.substr(0, 3) + ".txt"))
        texture_text_file = File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id.substr(0, 3) + ".txt";

      std::string refer_game_id;

      std::ifstream stream;
      File::OpenFStream(stream, texture_text_file, std::ios_base::out);
      if (stream.good())
        std::getline(stream, refer_game_id);

      const std::string refer_texture_directory = File::GetUserPath(D_HIRESTEXTURES_IDX) + refer_game_id;
      if (!File::Exists(refer_texture_directory))
        return File::GetUserPath(D_HIRESTEXTURES_IDX) + refer_game_id.substr(0, 3);
      return refer_texture_directory;
    }

    return File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id.substr(0, 3);
  }

  return texture_directory;
}
Super Mario 64 - Super Smash Bros. 64 - Mario Kart 64 - Zelda 64 - Star Fox 64 - Patreon - Discord
Find
Reply
11-10-2018, 01:01 AM (This post was last modified: 11-10-2018, 07:29 PM by Admentus.)
#2
Admentus Offline
Nothing but perfection for gaming
*******
Posts: 1,967
Threads: 25
Joined: May 2015
Wow... I think I finally did it? Please don't be too harsh on me. Tongue

https://github.com/dolphin-emu/dolphin/pull/7556

I am really a novice here, but I love to learn and improve myself. Perhaps my idea just sucks, that's OK too. At least I learned quite a lot by going through the process itself.

I used GitHub a few time previously to showcase my academic works individually. Ohh yeah, my GitHub name refers me as DevRobDev.... And Admentus was already taken. Sooo...
Super Mario 64 - Super Smash Bros. 64 - Mario Kart 64 - Zelda 64 - Star Fox 64 - Patreon - Discord
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode