@@ -0,0 +1,25 @@ | |||
#pragma once | |||
#include "common.hpp" | |||
namespace rack { | |||
struct Plugin; | |||
struct AssetManager { | |||
std::string systemDir; | |||
std::string userDir; | |||
AssetManager(); | |||
/** Returns the path of a system resource. Should only read files from this location. */ | |||
std::string system(std::string filename); | |||
/** Returns the path of a user resource. Can read and write files to this location. */ | |||
std::string user(std::string filename); | |||
/** Returns the path of a resource in the plugin's folder. Should only read files from this location. */ | |||
std::string plugin(Plugin *plugin, std::string filename); | |||
}; | |||
} // namespace rack |
@@ -1,24 +0,0 @@ | |||
#pragma once | |||
#include "common.hpp" | |||
#include "plugin/Plugin.hpp" | |||
namespace rack { | |||
namespace asset { | |||
void init(); | |||
/** Returns the path of a system resource. Should only read files from this location. */ | |||
std::string system(std::string filename); | |||
/** Returns the path of a user resource. Can read and write files to this location. */ | |||
std::string user(std::string filename); | |||
/** Returns the path of a resource in the plugin's folder. Should only read files from this location. */ | |||
std::string plugin(Plugin *plugin, std::string filename); | |||
extern std::string systemDir; | |||
extern std::string userDir; | |||
} // namespace asset | |||
} // namespace rack |
@@ -35,25 +35,25 @@ struct RoundKnob : SVGKnob { | |||
struct RoundBlackKnob : RoundKnob { | |||
RoundBlackKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundBlackKnob.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/RoundBlackKnob.svg"))); | |||
} | |||
}; | |||
struct RoundSmallBlackKnob : RoundKnob { | |||
RoundSmallBlackKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundSmallBlackKnob.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/RoundSmallBlackKnob.svg"))); | |||
} | |||
}; | |||
struct RoundLargeBlackKnob : RoundKnob { | |||
RoundLargeBlackKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundLargeBlackKnob.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/RoundLargeBlackKnob.svg"))); | |||
} | |||
}; | |||
struct RoundHugeBlackKnob : RoundKnob { | |||
RoundHugeBlackKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundHugeBlackKnob.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/RoundHugeBlackKnob.svg"))); | |||
} | |||
}; | |||
@@ -75,37 +75,37 @@ struct Davies1900hKnob : SVGKnob { | |||
struct Davies1900hWhiteKnob : Davies1900hKnob { | |||
Davies1900hWhiteKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Davies1900hWhite.svg"))); | |||
} | |||
}; | |||
struct Davies1900hBlackKnob : Davies1900hKnob { | |||
Davies1900hBlackKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hBlack.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Davies1900hBlack.svg"))); | |||
} | |||
}; | |||
struct Davies1900hRedKnob : Davies1900hKnob { | |||
Davies1900hRedKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Davies1900hRed.svg"))); | |||
} | |||
}; | |||
struct Davies1900hLargeWhiteKnob : Davies1900hKnob { | |||
Davies1900hLargeWhiteKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Davies1900hLargeWhite.svg"))); | |||
} | |||
}; | |||
struct Davies1900hLargeBlackKnob : Davies1900hKnob { | |||
Davies1900hLargeBlackKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeBlack.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Davies1900hLargeBlack.svg"))); | |||
} | |||
}; | |||
struct Davies1900hLargeRedKnob : Davies1900hKnob { | |||
Davies1900hLargeRedKnob() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Davies1900hLargeRed.svg"))); | |||
} | |||
}; | |||
@@ -119,163 +119,163 @@ struct Rogan : SVGKnob { | |||
struct Rogan6PSWhite : Rogan { | |||
Rogan6PSWhite() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan6PSWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan6PSWhite.svg"))); | |||
} | |||
}; | |||
struct Rogan5PSGray : Rogan { | |||
Rogan5PSGray() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan5PSGray.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan5PSGray.svg"))); | |||
} | |||
}; | |||
struct Rogan3PSBlue : Rogan { | |||
Rogan3PSBlue() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSBlue.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PSBlue.svg"))); | |||
} | |||
}; | |||
struct Rogan3PSRed : Rogan { | |||
Rogan3PSRed() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PSRed.svg"))); | |||
} | |||
}; | |||
struct Rogan3PSGreen : Rogan { | |||
Rogan3PSGreen() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSGreen.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PSGreen.svg"))); | |||
} | |||
}; | |||
struct Rogan3PSWhite : Rogan { | |||
Rogan3PSWhite() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PSWhite.svg"))); | |||
} | |||
}; | |||
struct Rogan3PBlue : Rogan { | |||
Rogan3PBlue() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PBlue.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PBlue.svg"))); | |||
} | |||
}; | |||
struct Rogan3PRed : Rogan { | |||
Rogan3PRed() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PRed.svg"))); | |||
} | |||
}; | |||
struct Rogan3PGreen : Rogan { | |||
Rogan3PGreen() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PGreen.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PGreen.svg"))); | |||
} | |||
}; | |||
struct Rogan3PWhite : Rogan { | |||
Rogan3PWhite() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan3PWhite.svg"))); | |||
} | |||
}; | |||
struct Rogan2SGray : Rogan { | |||
Rogan2SGray() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2SGray.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2SGray.svg"))); | |||
} | |||
}; | |||
struct Rogan2PSBlue : Rogan { | |||
Rogan2PSBlue() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSBlue.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PSBlue.svg"))); | |||
} | |||
}; | |||
struct Rogan2PSRed : Rogan { | |||
Rogan2PSRed() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PSRed.svg"))); | |||
} | |||
}; | |||
struct Rogan2PSGreen : Rogan { | |||
Rogan2PSGreen() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSGreen.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PSGreen.svg"))); | |||
} | |||
}; | |||
struct Rogan2PSWhite : Rogan { | |||
Rogan2PSWhite() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PSWhite.svg"))); | |||
} | |||
}; | |||
struct Rogan2PBlue : Rogan { | |||
Rogan2PBlue() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PBlue.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PBlue.svg"))); | |||
} | |||
}; | |||
struct Rogan2PRed : Rogan { | |||
Rogan2PRed() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PRed.svg"))); | |||
} | |||
}; | |||
struct Rogan2PGreen : Rogan { | |||
Rogan2PGreen() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PGreen.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PGreen.svg"))); | |||
} | |||
}; | |||
struct Rogan2PWhite : Rogan { | |||
Rogan2PWhite() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan2PWhite.svg"))); | |||
} | |||
}; | |||
struct Rogan1PSBlue : Rogan { | |||
Rogan1PSBlue() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSBlue.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PSBlue.svg"))); | |||
} | |||
}; | |||
struct Rogan1PSRed : Rogan { | |||
Rogan1PSRed() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PSRed.svg"))); | |||
} | |||
}; | |||
struct Rogan1PSGreen : Rogan { | |||
Rogan1PSGreen() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSGreen.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PSGreen.svg"))); | |||
} | |||
}; | |||
struct Rogan1PSWhite : Rogan { | |||
Rogan1PSWhite() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PSWhite.svg"))); | |||
} | |||
}; | |||
struct Rogan1PBlue : Rogan { | |||
Rogan1PBlue() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PBlue.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PBlue.svg"))); | |||
} | |||
}; | |||
struct Rogan1PRed : Rogan { | |||
Rogan1PRed() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PRed.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PRed.svg"))); | |||
} | |||
}; | |||
struct Rogan1PGreen : Rogan { | |||
Rogan1PGreen() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PGreen.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PGreen.svg"))); | |||
} | |||
}; | |||
struct Rogan1PWhite : Rogan { | |||
Rogan1PWhite() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PWhite.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Rogan1PWhite.svg"))); | |||
} | |||
}; | |||
@@ -284,9 +284,9 @@ struct SynthTechAlco : SVGKnob { | |||
SynthTechAlco() { | |||
minAngle = -0.82*M_PI; | |||
maxAngle = 0.82*M_PI; | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/SynthTechAlco.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/SynthTechAlco.svg"))); | |||
SVGWidget *cap = new SVGWidget; | |||
cap->setSVG(SVG::load(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg"))); | |||
cap->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/SynthTechAlco_cap.svg"))); | |||
addChild(cap); | |||
} | |||
}; | |||
@@ -295,7 +295,7 @@ struct Trimpot : SVGKnob { | |||
Trimpot() { | |||
minAngle = -0.75*M_PI; | |||
maxAngle = 0.75*M_PI; | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Trimpot.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/Trimpot.svg"))); | |||
} | |||
}; | |||
@@ -303,7 +303,7 @@ struct BefacoBigKnob : SVGKnob { | |||
BefacoBigKnob() { | |||
minAngle = -0.75*M_PI; | |||
maxAngle = 0.75*M_PI; | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/BefacoBigKnob.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoBigKnob.svg"))); | |||
} | |||
}; | |||
@@ -319,7 +319,7 @@ struct BefacoTinyKnob : SVGKnob { | |||
BefacoTinyKnob() { | |||
minAngle = -0.75*M_PI; | |||
maxAngle = 0.75*M_PI; | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoTinyKnob.svg"))); | |||
} | |||
}; | |||
@@ -328,7 +328,7 @@ struct BefacoSlidePot : SVGSlider { | |||
Vec margin = Vec(3.5, 3.5); | |||
maxHandlePos = Vec(-1, -2).plus(margin); | |||
minHandlePos = Vec(-1, 87).plus(margin); | |||
setSVGs(SVG::load(asset::system("res/ComponentLibrary/BefacoSlidePot.svg")), SVG::load(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg"))); | |||
setSVGs(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoSlidePot.svg")), SVG::load(context()->asset->system("res/ComponentLibrary/BefacoSlidePotHandle.svg"))); | |||
background->box.pos = margin; | |||
box.size = background->box.size.plus(margin.mult(2)); | |||
} | |||
@@ -338,38 +338,38 @@ struct LEDSlider : SVGSlider { | |||
LEDSlider() { | |||
maxHandlePos = mm2px(Vec(0.738, 0.738).plus(Vec(2, 0))); | |||
minHandlePos = mm2px(Vec(0.738, 22.078).plus(Vec(2, 0))); | |||
setSVGs(SVG::load(asset::system("res/ComponentLibrary/LEDSlider.svg")), NULL); | |||
setSVGs(SVG::load(context()->asset->system("res/ComponentLibrary/LEDSlider.svg")), NULL); | |||
} | |||
}; | |||
/** API is unstable for LEDSlider. Will add a LightWidget later. */ | |||
struct LEDSliderGreen : LEDSlider { | |||
LEDSliderGreen() { | |||
handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderGreenHandle.svg"))); | |||
handle->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/LEDSliderGreenHandle.svg"))); | |||
} | |||
}; | |||
struct LEDSliderRed : LEDSlider { | |||
LEDSliderRed() { | |||
handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderRedHandle.svg"))); | |||
handle->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/LEDSliderRedHandle.svg"))); | |||
} | |||
}; | |||
struct LEDSliderYellow : LEDSlider { | |||
LEDSliderYellow() { | |||
handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderYellowHandle.svg"))); | |||
handle->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/LEDSliderYellowHandle.svg"))); | |||
} | |||
}; | |||
struct LEDSliderBlue : LEDSlider { | |||
LEDSliderBlue() { | |||
handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderBlueHandle.svg"))); | |||
handle->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/LEDSliderBlueHandle.svg"))); | |||
} | |||
}; | |||
struct LEDSliderWhite : LEDSlider { | |||
LEDSliderWhite() { | |||
handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderWhiteHandle.svg"))); | |||
handle->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/LEDSliderWhiteHandle.svg"))); | |||
} | |||
}; | |||
@@ -379,19 +379,19 @@ struct LEDSliderWhite : LEDSlider { | |||
struct PJ301MPort : SVGPort { | |||
PJ301MPort() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ301M.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/PJ301M.svg"))); | |||
} | |||
}; | |||
struct PJ3410Port : SVGPort { | |||
PJ3410Port() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ3410.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/PJ3410.svg"))); | |||
} | |||
}; | |||
struct CL1362Port : SVGPort { | |||
CL1362Port() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/CL1362.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/CL1362.svg"))); | |||
} | |||
}; | |||
@@ -514,83 +514,83 @@ struct PB61303Light : BASE { | |||
struct NKK : SVGSwitch, ToggleSwitch { | |||
NKK() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_1.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_2.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/NKK_0.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/NKK_1.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/NKK_2.svg"))); | |||
} | |||
}; | |||
struct CKSS : SVGSwitch, ToggleSwitch { | |||
CKSS() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_1.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/CKSS_0.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/CKSS_1.svg"))); | |||
} | |||
}; | |||
struct CKSSThree : SVGSwitch, ToggleSwitch { | |||
CKSSThree() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_1.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_2.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/CKSSThree_0.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/CKSSThree_1.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/CKSSThree_2.svg"))); | |||
} | |||
}; | |||
struct CKD6 : SVGSwitch, MomentarySwitch { | |||
CKD6() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_1.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/CKD6_0.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/CKD6_1.svg"))); | |||
} | |||
}; | |||
struct TL1105 : SVGSwitch, MomentarySwitch { | |||
TL1105() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/TL1105_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/TL1105_1.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/TL1105_0.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/TL1105_1.svg"))); | |||
} | |||
}; | |||
struct LEDButton : SVGSwitch, MomentarySwitch { | |||
LEDButton() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDButton.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/LEDButton.svg"))); | |||
} | |||
}; | |||
struct BefacoSwitch : SVGSwitch, ToggleSwitch { | |||
BefacoSwitch() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoSwitch_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoSwitch_1.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoSwitch_2.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoSwitch_0.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoSwitch_1.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoSwitch_2.svg"))); | |||
} | |||
}; | |||
struct BefacoPush : SVGSwitch, MomentarySwitch { | |||
BefacoPush() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoPush_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoPush_1.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoPush_0.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/BefacoPush_1.svg"))); | |||
} | |||
}; | |||
struct LEDBezel : SVGSwitch, MomentarySwitch { | |||
LEDBezel() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDBezel.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/LEDBezel.svg"))); | |||
} | |||
}; | |||
struct PB61303 : SVGSwitch, MomentarySwitch { | |||
PB61303() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/PB61303.svg"))); | |||
addFrame(SVG::load(context()->asset->system("res/ComponentLibrary/PB61303.svg"))); | |||
} | |||
}; | |||
struct PB61303Button : SVGButton { | |||
PB61303Button() { | |||
setSVGs(SVG::load(asset::system("res/ComponentLibrary/PB61303.svg")), NULL); | |||
setSVGs(SVG::load(context()->asset->system("res/ComponentLibrary/PB61303.svg")), NULL); | |||
} | |||
}; | |||
struct LEDBezelButton : SVGButton { | |||
LEDBezelButton() { | |||
setSVGs(SVG::load(asset::system("res/ComponentLibrary/LEDBezel.svg")), NULL); | |||
setSVGs(SVG::load(context()->asset->system("res/ComponentLibrary/LEDBezel.svg")), NULL); | |||
} | |||
}; | |||
@@ -600,14 +600,14 @@ struct LEDBezelButton : SVGButton { | |||
struct ScrewSilver : SVGScrew { | |||
ScrewSilver() { | |||
sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewSilver.svg"))); | |||
sw->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/ScrewSilver.svg"))); | |||
box.size = sw->box.size; | |||
} | |||
}; | |||
struct ScrewBlack : SVGScrew { | |||
ScrewBlack() { | |||
sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewBlack.svg"))); | |||
sw->setSVG(SVG::load(context()->asset->system("res/ComponentLibrary/ScrewBlack.svg"))); | |||
box.size = sw->box.size; | |||
} | |||
}; | |||
@@ -5,13 +5,15 @@ | |||
namespace rack { | |||
struct Scene; | |||
struct Engine; | |||
namespace event { | |||
struct Context; | |||
} | |||
struct Scene; | |||
struct Engine; | |||
struct PluginManager; | |||
struct AssetManager; | |||
struct Context { | |||
bool devMode = false; | |||
@@ -19,6 +21,8 @@ struct Context { | |||
event::Context *event = NULL; | |||
Scene *scene = NULL; | |||
Engine *engine = NULL; | |||
PluginManager *plugin = NULL; | |||
AssetManager *asset = NULL; | |||
}; | |||
@@ -29,8 +29,6 @@ struct PluginManager { | |||
Model *getModel(std::string pluginSlug, std::string modelSlug); | |||
}; | |||
extern PluginManager *gPluginManager; | |||
} // namespace rack | |||
@@ -7,7 +7,7 @@ | |||
#include "system.hpp" | |||
#include "random.hpp" | |||
#include "network.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "window.hpp" | |||
#include "context.hpp" | |||
#include "helpers.hpp" | |||
@@ -69,9 +69,9 @@ DEPRECATED inline float randomf() {return random::uniform();} | |||
// asset | |||
//////////////////// | |||
DEPRECATED inline std::string assetGlobal(std::string filename) {return asset::system(filename);} | |||
DEPRECATED inline std::string assetLocal(std::string filename) {return asset::user(filename);} | |||
DEPRECATED inline std::string assetPlugin(Plugin *plugin, std::string filename) {return asset::plugin(plugin, filename);} | |||
DEPRECATED inline std::string assetGlobal(std::string filename) {return context()->asset->system(filename);} | |||
DEPRECATED inline std::string assetLocal(std::string filename) {return context()->asset->user(filename);} | |||
DEPRECATED inline std::string assetPlugin(Plugin *plugin, std::string filename) {return context()->asset->plugin(plugin, filename);} | |||
//////////////////// | |||
// color | |||
@@ -1,6 +1,7 @@ | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "system.hpp" | |||
#include "context.hpp" | |||
#include "plugin/Plugin.hpp" | |||
#if ARCH_MAC | |||
#include <CoreFoundation/CoreFoundation.h> | |||
@@ -21,14 +22,9 @@ | |||
namespace rack { | |||
namespace asset { | |||
std::string systemDir; | |||
std::string userDir; | |||
void init() { | |||
AssetManager::AssetManager() { | |||
// Get system dir | |||
if (systemDir.empty()) { | |||
if (context()->devMode) { | |||
@@ -99,21 +95,20 @@ void init() { | |||
} | |||
std::string system(std::string filename) { | |||
std::string AssetManager::system(std::string filename) { | |||
return systemDir + "/" + filename; | |||
} | |||
std::string user(std::string filename) { | |||
std::string AssetManager::user(std::string filename) { | |||
return userDir + "/" + filename; | |||
} | |||
std::string plugin(Plugin *plugin, std::string filename) { | |||
std::string AssetManager::plugin(Plugin *plugin, std::string filename) { | |||
assert(plugin); | |||
return plugin->path + "/" + filename; | |||
} | |||
} // namespace asset | |||
} // namespace rack |
@@ -240,7 +240,7 @@ void AudioInterface::step() { | |||
struct AudioInterfaceWidget : ModuleWidget { | |||
AudioInterfaceWidget(AudioInterface *module) : ModuleWidget(module) { | |||
setPanel(SVG::load(asset::system("res/Core/AudioInterface.svg"))); | |||
setPanel(SVG::load(context()->asset->system("res/Core/AudioInterface.svg"))); | |||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | |||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | |||
@@ -182,7 +182,7 @@ struct MidiCcWidget : Grid16MidiWidget { | |||
struct MIDICCToCVInterfaceWidget : ModuleWidget { | |||
MIDICCToCVInterfaceWidget(MIDICCToCVInterface *module) : ModuleWidget(module) { | |||
setPanel(SVG::load(asset::system("res/Core/MIDICCToCVInterface.svg"))); | |||
setPanel(SVG::load(context()->asset->system("res/Core/MIDICCToCVInterface.svg"))); | |||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | |||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | |||
@@ -261,7 +261,7 @@ struct MIDIToCVInterface : Module { | |||
struct MIDIToCVInterfaceWidget : ModuleWidget { | |||
MIDIToCVInterfaceWidget(MIDIToCVInterface *module) : ModuleWidget(module) { | |||
setPanel(SVG::load(asset::system("res/Core/MIDIToCVInterface.svg"))); | |||
setPanel(SVG::load(context()->asset->system("res/Core/MIDIToCVInterface.svg"))); | |||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | |||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | |||
@@ -201,7 +201,7 @@ struct MidiTrigWidget : Grid16MidiWidget { | |||
struct MIDITriggerToCVInterfaceWidget : ModuleWidget { | |||
MIDITriggerToCVInterfaceWidget(MIDITriggerToCVInterface *module) : ModuleWidget(module) { | |||
setPanel(SVG::load(asset::system("res/Core/MIDITriggerToCVInterface.svg"))); | |||
setPanel(SVG::load(context()->asset->system("res/Core/MIDITriggerToCVInterface.svg"))); | |||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | |||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | |||
@@ -8,7 +8,7 @@ struct NotesWidget : ModuleWidget { | |||
TextField *textField; | |||
NotesWidget(Module *module) : ModuleWidget(module) { | |||
setPanel(SVG::load(asset::system("res/Core/Notes.svg"))); | |||
setPanel(SVG::load(context()->asset->system("res/Core/Notes.svg"))); | |||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | |||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | |||
@@ -303,7 +303,7 @@ struct QuadMIDIToCVInterface : Module { | |||
struct QuadMIDIToCVInterfaceWidget : ModuleWidget { | |||
QuadMIDIToCVInterfaceWidget(QuadMIDIToCVInterface *module) : ModuleWidget(module) { | |||
setPanel(SVG::load(asset::system("res/Core/QuadMIDIToCVInterface.svg"))); | |||
setPanel(SVG::load(context()->asset->system("res/Core/QuadMIDIToCVInterface.svg"))); | |||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | |||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | |||
@@ -1,5 +1,5 @@ | |||
#include "app/LedDisplay.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "window.hpp" | |||
#include "event.hpp" | |||
#include "context.hpp" | |||
@@ -34,7 +34,7 @@ void LedDisplaySeparator::draw(NVGcontext *vg) { | |||
LedDisplayChoice::LedDisplayChoice() { | |||
box.size = mm2px(Vec(0, 28.0 / 3)); | |||
font = Font::load(asset::system("res/fonts/ShareTechMono-Regular.ttf")); | |||
font = Font::load(context()->asset->system("res/fonts/ShareTechMono-Regular.ttf")); | |||
color = nvgRGB(0xff, 0xd7, 0x14); | |||
textOffset = Vec(10, 18); | |||
} | |||
@@ -64,7 +64,7 @@ void LedDisplayChoice::onButton(event::Button &e) { | |||
LedDisplayTextField::LedDisplayTextField() { | |||
font = Font::load(asset::system("res/fonts/ShareTechMono-Regular.ttf")); | |||
font = Font::load(context()->asset->system("res/fonts/ShareTechMono-Regular.ttf")); | |||
color = nvgRGB(0xff, 0xd7, 0x14); | |||
textOffset = Vec(5, 5); | |||
} | |||
@@ -323,7 +323,7 @@ struct ModuleBrowser : OpaqueWidget { | |||
addChild(moduleScroll); | |||
// Collect authors | |||
for (Plugin *plugin : gPluginManager->plugins) { | |||
for (Plugin *plugin : context()->plugin->plugins) { | |||
for (Model *model : plugin->models) { | |||
// Insert author | |||
if (!model->author.empty()) | |||
@@ -428,7 +428,7 @@ struct ModuleBrowser : OpaqueWidget { | |||
moduleList->addChild(item); | |||
} | |||
// Modules | |||
for (Plugin *plugin : gPluginManager->plugins) { | |||
for (Plugin *plugin : context()->plugin->plugins) { | |||
for (Model *model : plugin->models) { | |||
if (isModelFiltered(model) && isModelMatch(model, search)) { | |||
ModelItem *item = new ModelItem; | |||
@@ -588,7 +588,7 @@ void moduleBrowserFromJson(json_t *rootJ) { | |||
continue; | |||
std::string pluginSlug = json_string_value(pluginJ); | |||
std::string modelSlug = json_string_value(modelJ); | |||
Model *model = gPluginManager->getModel(pluginSlug, modelSlug); | |||
Model *model = context()->plugin->getModel(pluginSlug, modelSlug); | |||
if (!model) | |||
continue; | |||
sFavoriteModels.insert(model); | |||
@@ -2,7 +2,7 @@ | |||
#include "engine/Engine.hpp" | |||
#include "logger.hpp" | |||
#include "system.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "app/Scene.hpp" | |||
#include "helpers.hpp" | |||
#include "context.hpp" | |||
@@ -185,7 +185,7 @@ void ModuleWidget::save(std::string filename) { | |||
} | |||
void ModuleWidget::loadDialog() { | |||
std::string dir = asset::user("presets"); | |||
std::string dir = context()->asset->user("presets"); | |||
system::createDirectory(dir); | |||
osdialog_filters *filters = osdialog_filters_parse(PRESET_FILTERS.c_str()); | |||
@@ -198,7 +198,7 @@ void ModuleWidget::loadDialog() { | |||
} | |||
void ModuleWidget::saveDialog() { | |||
std::string dir = asset::user("presets"); | |||
std::string dir = context()->asset->user("presets"); | |||
system::createDirectory(dir); | |||
osdialog_filters *filters = osdialog_filters_parse(PRESET_FILTERS.c_str()); | |||
@@ -8,6 +8,7 @@ | |||
#include "ui/PasswordField.hpp" | |||
#include "ui/Label.hpp" | |||
#include "plugin/PluginManager.hpp" | |||
#include "context.hpp" | |||
#include "window.hpp" | |||
#include "helpers.hpp" | |||
#include "osdialog.h" | |||
@@ -31,7 +32,7 @@ struct LogInButton : Button { | |||
TextField *passwordField; | |||
void onAction(event::Action &e) override { | |||
std::thread t([&]() { | |||
gPluginManager->logIn(emailField->text, passwordField->text); | |||
context()->plugin->logIn(emailField->text, passwordField->text); | |||
}); | |||
t.detach(); | |||
passwordField->text = ""; | |||
@@ -41,7 +42,7 @@ struct LogInButton : Button { | |||
struct StatusLabel : Label { | |||
void step() override { | |||
text = gPluginManager->loginStatus; | |||
text = context()->plugin->loginStatus; | |||
} | |||
}; | |||
@@ -67,7 +68,7 @@ struct SyncButton : Button { | |||
// Check for plugin update on first step() | |||
if (!checked) { | |||
std::thread t([this]() { | |||
if (gPluginManager->sync(true)) | |||
if (context()->plugin->sync(true)) | |||
available = true; | |||
}); | |||
t.detach(); | |||
@@ -96,7 +97,7 @@ struct SyncButton : Button { | |||
void onAction(event::Action &e) override { | |||
available = false; | |||
std::thread t([this]() { | |||
if (gPluginManager->sync(false)) | |||
if (context()->plugin->sync(false)) | |||
completed = true; | |||
}); | |||
t.detach(); | |||
@@ -106,14 +107,14 @@ struct SyncButton : Button { | |||
struct LogOutButton : Button { | |||
void onAction(event::Action &e) override { | |||
gPluginManager->logOut(); | |||
context()->plugin->logOut(); | |||
} | |||
}; | |||
struct DownloadQuantity : Quantity { | |||
float getValue() override { | |||
return gPluginManager->downloadProgress; | |||
return context()->plugin->downloadProgress; | |||
} | |||
float getDisplayValue() override { | |||
@@ -123,7 +124,7 @@ struct DownloadQuantity : Quantity { | |||
int getDisplayPrecision() override {return 0;} | |||
std::string getLabel() override { | |||
return "Downloading " + gPluginManager->downloadName; | |||
return "Downloading " + context()->plugin->downloadName; | |||
} | |||
std::string getUnit() override {return "%";} | |||
@@ -139,7 +140,7 @@ struct DownloadProgressBar : ProgressBar { | |||
struct CancelButton : Button { | |||
void onAction(event::Action &e) override { | |||
gPluginManager->cancelDownload(); | |||
context()->plugin->cancelDownload(); | |||
} | |||
}; | |||
@@ -226,9 +227,9 @@ void PluginManagerWidget::step() { | |||
manageWidget->visible = false; | |||
downloadWidget->visible = false; | |||
if (gPluginManager->isDownloading) | |||
if (context()->plugin->isDownloading) | |||
downloadWidget->visible = true; | |||
else if (gPluginManager->isLoggedIn()) | |||
else if (context()->plugin->isLoggedIn()) | |||
manageWidget->visible = true; | |||
else | |||
loginWidget->visible = true; | |||
@@ -6,7 +6,7 @@ | |||
#include "app/ModuleBrowser.hpp" | |||
#include "osdialog.h" | |||
#include "settings.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "system.hpp" | |||
#include "logger.hpp" | |||
#include "plugin/PluginManager.hpp" | |||
@@ -67,7 +67,7 @@ void RackWidget::reset() { | |||
if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "Clear patch and start over?")) { | |||
clear(); | |||
// Fails silently if file does not exist | |||
load(asset::user("template.vcv")); | |||
load(context()->asset->user("template.vcv")); | |||
lastPath = ""; | |||
} | |||
} | |||
@@ -75,7 +75,7 @@ void RackWidget::reset() { | |||
void RackWidget::loadDialog() { | |||
std::string dir; | |||
if (lastPath.empty()) { | |||
dir = asset::user("patches"); | |||
dir = context()->asset->user("patches"); | |||
system::createDirectory(dir); | |||
} | |||
else { | |||
@@ -104,7 +104,7 @@ void RackWidget::saveAsDialog() { | |||
std::string dir; | |||
std::string filename; | |||
if (lastPath.empty()) { | |||
dir = asset::user("patches"); | |||
dir = context()->asset->user("patches"); | |||
system::createDirectory(dir); | |||
} | |||
else { | |||
@@ -379,7 +379,7 @@ ModuleWidget *RackWidget::moduleFromJson(json_t *moduleJ) { | |||
std::string modelSlug = json_string_value(modelSlugJ); | |||
// Get Model | |||
Model *model = gPluginManager->getModel(pluginSlug, modelSlug); | |||
Model *model = context()->plugin->getModel(pluginSlug, modelSlug); | |||
if (!model) | |||
return NULL; | |||
@@ -494,8 +494,8 @@ void RackWidget::step() { | |||
// Autosave every 15 seconds | |||
if (gGuiFrame % (60 * 15) == 0) { | |||
save(asset::user("autosave.vcv")); | |||
settings::save(asset::user("settings.json")); | |||
save(context()->asset->user("autosave.vcv")); | |||
settings::save(context()->asset->user("settings.json")); | |||
} | |||
Widget::step(); | |||
@@ -1,7 +1,7 @@ | |||
#include "app/Toolbar.hpp" | |||
#include "window.hpp" | |||
#include "engine/Engine.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "ui/Tooltip.hpp" | |||
#include "ui/IconButton.hpp" | |||
#include "ui/SequentialLayout.hpp" | |||
@@ -39,7 +39,7 @@ struct TooltipIconButton : IconButton { | |||
struct NewButton : TooltipIconButton { | |||
NewButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_146097_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_146097_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "New patch (" WINDOW_MOD_KEY_NAME "+N)";} | |||
void onAction(event::Action &e) override { | |||
@@ -49,7 +49,7 @@ struct NewButton : TooltipIconButton { | |||
struct OpenButton : TooltipIconButton { | |||
OpenButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_31859_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_31859_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Open patch (" WINDOW_MOD_KEY_NAME "+O)";} | |||
void onAction(event::Action &e) override { | |||
@@ -59,7 +59,7 @@ struct OpenButton : TooltipIconButton { | |||
struct SaveButton : TooltipIconButton { | |||
SaveButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_1343816_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_1343816_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Save patch (" WINDOW_MOD_KEY_NAME "+S)";} | |||
void onAction(event::Action &e) override { | |||
@@ -69,7 +69,7 @@ struct SaveButton : TooltipIconButton { | |||
struct SaveAsButton : TooltipIconButton { | |||
SaveAsButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_1343811_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_1343811_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Save patch as (" WINDOW_MOD_KEY_NAME "+Shift+S)";} | |||
void onAction(event::Action &e) override { | |||
@@ -79,7 +79,7 @@ struct SaveAsButton : TooltipIconButton { | |||
struct RevertButton : TooltipIconButton { | |||
RevertButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_1084369_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_1084369_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Revert patch";} | |||
void onAction(event::Action &e) override { | |||
@@ -89,7 +89,7 @@ struct RevertButton : TooltipIconButton { | |||
struct DisconnectCablesButton : TooltipIconButton { | |||
DisconnectCablesButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_1745061_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_1745061_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Disconnect cables";} | |||
void onAction(event::Action &e) override { | |||
@@ -99,7 +99,7 @@ struct DisconnectCablesButton : TooltipIconButton { | |||
struct PowerMeterButton : TooltipIconButton { | |||
PowerMeterButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_305536_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_305536_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Toggle power meter (see manual for explanation)";} | |||
void onAction(event::Action &e) override { | |||
@@ -123,7 +123,7 @@ struct SampleRateItem : MenuItem { | |||
struct SampleRateButton : TooltipIconButton { | |||
SampleRateButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_1240789_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_1240789_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Engine sample rate";} | |||
void onAction(event::Action &e) override { | |||
@@ -150,7 +150,7 @@ struct SampleRateButton : TooltipIconButton { | |||
struct RackLockButton : TooltipIconButton { | |||
RackLockButton() { | |||
setSVG(SVG::load(asset::system("res/icons/noun_468341_cc.svg"))); | |||
setSVG(SVG::load(context()->asset->system("res/icons/noun_468341_cc.svg"))); | |||
} | |||
std::string getTooltipText() override {return "Lock modules";} | |||
void onAction(event::Action &e) override { | |||
@@ -238,7 +238,7 @@ Toolbar::Toolbar() { | |||
layout->addChild(zoomSlider); | |||
// Kind of hacky, but display the PluginManagerWidget only if the user directory is not the development directory | |||
if (asset::user("") != "./") { | |||
if (context()->asset->user("") != "./") { | |||
Widget *pluginManager = new PluginManagerWidget; | |||
layout->addChild(pluginManager); | |||
} | |||
@@ -1,5 +1,5 @@ | |||
#include "logger.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "context.hpp" | |||
#include <chrono> | |||
@@ -18,7 +18,7 @@ void init() { | |||
outputFile = stderr; | |||
} | |||
else { | |||
std::string logFilename = asset::user("log.txt"); | |||
std::string logFilename = context()->asset->user("log.txt"); | |||
outputFile = fopen(logFilename.c_str(), "w"); | |||
} | |||
} | |||
@@ -1,7 +1,7 @@ | |||
#include "common.hpp" | |||
#include "random.hpp" | |||
#include "logger.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "rtmidi.hpp" | |||
#include "keyboard.hpp" | |||
#include "gamepad.hpp" | |||
@@ -46,10 +46,10 @@ int main(int argc, char *argv[]) { | |||
context()->devMode = true; | |||
} break; | |||
case 's': { | |||
asset::systemDir = optarg; | |||
context()->asset->systemDir = optarg; | |||
} break; | |||
case 'u': { | |||
asset::userDir = optarg; | |||
context()->asset->userDir = optarg; | |||
} break; | |||
default: break; | |||
} | |||
@@ -60,19 +60,19 @@ int main(int argc, char *argv[]) { | |||
// Initialize environment | |||
random::init(); | |||
asset::init(); | |||
context()->asset = new AssetManager; | |||
logger::init(); | |||
// Log environment | |||
INFO("%s %s", APP_NAME.c_str(), APP_VERSION.c_str()); | |||
if (context()->devMode) | |||
INFO("Development mode"); | |||
INFO("System directory: %s", asset::system("").c_str()); | |||
INFO("User directory: %s", asset::user("").c_str()); | |||
INFO("System directory: %s", context()->asset->system("").c_str()); | |||
INFO("User directory: %s", context()->asset->user("").c_str()); | |||
// Initialize app | |||
tagsInit(); | |||
gPluginManager = new PluginManager; | |||
context()->plugin = new PluginManager; | |||
context()->engine = new Engine; | |||
rtmidiInit(); | |||
bridgeInit(); | |||
@@ -82,13 +82,13 @@ int main(int argc, char *argv[]) { | |||
context()->scene = new Scene; | |||
context()->event->rootWidget = context()->scene; | |||
windowInit(); | |||
settings::load(asset::user("settings.json")); | |||
settings::load(context()->asset->user("settings.json")); | |||
if (patchFile.empty()) { | |||
// To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded. | |||
bool oldSkipAutosaveOnLaunch = settings::gSkipAutosaveOnLaunch; | |||
settings::gSkipAutosaveOnLaunch = true; | |||
settings::save(asset::user("settings.json")); | |||
settings::save(context()->asset->user("settings.json")); | |||
settings::gSkipAutosaveOnLaunch = false; | |||
if (oldSkipAutosaveOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) { | |||
context()->scene->rackWidget->lastPath = ""; | |||
@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) { | |||
else { | |||
// Load autosave | |||
std::string oldLastPath = context()->scene->rackWidget->lastPath; | |||
context()->scene->rackWidget->load(asset::user("autosave.vcv")); | |||
context()->scene->rackWidget->load(context()->asset->user("autosave.vcv")); | |||
context()->scene->rackWidget->lastPath = oldLastPath; | |||
} | |||
} | |||
@@ -111,8 +111,8 @@ int main(int argc, char *argv[]) { | |||
context()->engine->stop(); | |||
// Destroy namespaces | |||
context()->scene->rackWidget->save(asset::user("autosave.vcv")); | |||
settings::save(asset::user("settings.json")); | |||
context()->scene->rackWidget->save(context()->asset->user("autosave.vcv")); | |||
settings::save(context()->asset->user("settings.json")); | |||
delete context()->scene; | |||
context()->scene = NULL; | |||
delete context()->event; | |||
@@ -122,8 +122,10 @@ int main(int argc, char *argv[]) { | |||
delete context()->engine; | |||
context()->engine = NULL; | |||
midiDestroy(); | |||
delete gPluginManager; | |||
gPluginManager = NULL; | |||
delete context()->plugin; | |||
context()->plugin = NULL; | |||
delete context()->asset; | |||
context()->asset = NULL; | |||
logger::destroy(); | |||
return 0; | |||
@@ -2,7 +2,7 @@ | |||
#include "system.hpp" | |||
#include "logger.hpp" | |||
#include "network.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "string.hpp" | |||
#include "context.hpp" | |||
#include "app/common.hpp" | |||
@@ -178,7 +178,7 @@ static bool PluginManager_syncPlugin(PluginManager *pluginManager, std::string s | |||
INFO("Downloading plugin %s %s %s", slug.c_str(), latestVersion.c_str(), arch.c_str()); | |||
// Download zip | |||
std::string pluginDest = asset::user("plugins/" + slug + ".zip"); | |||
std::string pluginDest = context()->asset->user("plugins/" + slug + ".zip"); | |||
if (!network::requestDownload(downloadUrl, pluginDest, &pluginManager->downloadProgress)) { | |||
WARN("Plugin %s download was unsuccessful", slug.c_str()); | |||
return false; | |||
@@ -308,14 +308,14 @@ PluginManager::PluginManager() { | |||
plugins.push_back(corePlugin); | |||
// Get user plugins directory | |||
std::string userPlugins = asset::user("plugins"); | |||
std::string userPlugins = context()->asset->user("plugins"); | |||
mkdir(userPlugins.c_str(), 0755); | |||
if (!context()->devMode) { | |||
// Copy Fundamental package to plugins directory if folder does not exist | |||
std::string fundamentalSrc = asset::system("Fundamental.zip"); | |||
std::string fundamentalDest = asset::user("plugins/Fundamental.zip"); | |||
std::string fundamentalDir = asset::user("plugins/Fundamental"); | |||
std::string fundamentalSrc = context()->asset->system("Fundamental.zip"); | |||
std::string fundamentalDest = context()->asset->user("plugins/Fundamental.zip"); | |||
std::string fundamentalDir = context()->asset->user("plugins/Fundamental"); | |||
if (system::isFile(fundamentalSrc) && !system::isFile(fundamentalDest) && !system::isDirectory(fundamentalDir)) { | |||
system::copyFile(fundamentalSrc, fundamentalDest); | |||
} | |||
@@ -482,7 +482,4 @@ Model *PluginManager::getModel(std::string pluginSlug, std::string modelSlug) { | |||
} | |||
PluginManager *gPluginManager = NULL; | |||
} // namespace rack |
@@ -21,7 +21,7 @@ static json_t *settingsToJson() { | |||
json_t *rootJ = json_object(); | |||
// token | |||
json_t *tokenJ = json_string(gPluginManager->token.c_str()); | |||
json_t *tokenJ = json_string(context()->plugin->token.c_str()); | |||
json_object_set_new(rootJ, "token", tokenJ); | |||
if (!windowIsMaximized()) { | |||
@@ -84,7 +84,7 @@ static void settingsFromJson(json_t *rootJ) { | |||
// token | |||
json_t *tokenJ = json_object_get(rootJ, "token"); | |||
if (tokenJ) | |||
gPluginManager->token = json_string_value(tokenJ); | |||
context()->plugin->token = json_string_value(tokenJ); | |||
// windowSize | |||
json_t *windowSizeJ = json_object_get(rootJ, "windowSize"); | |||
@@ -1,6 +1,6 @@ | |||
#include "window.hpp" | |||
#include "logger.hpp" | |||
#include "asset.hpp" | |||
#include "AssetManager.hpp" | |||
#include "app/Scene.hpp" | |||
#include "keyboard.hpp" | |||
#include "gamepad.hpp" | |||
@@ -257,7 +257,7 @@ void windowInit() { | |||
assert(gFramebufferVg); | |||
// Set up Blendish | |||
gGuiFont = Font::load(asset::system("res/fonts/DejaVuSans.ttf")); | |||
gGuiFont = Font::load(context()->asset->system("res/fonts/DejaVuSans.ttf")); | |||
bndSetFont(gGuiFont->handle); | |||
windowSetTheme(nvgRGB(0x33, 0x33, 0x33), nvgRGB(0xf0, 0xf0, 0xf0)); | |||