26 #ifndef AW_COLOR_GROUPS_HXX
29 #ifndef _GLIBCXX_STRING
33 #define is_assert(cond) arb_assert(cond)
50 float result_lower_bound;
51 float result_upper_bound;
54 return f>=0.0 && f<=1.0;
56 static CONSTEXPR_INLINE float shift_and_wrap(
const float& val,
const float& shift,
float wrapto) {
57 return shift>val ? val-shift+wrapto : val-shift;
60 float rephase_inbound(
float f)
const {
63 const float preshifted(shift_and_wrap(f, preshift, 1.0));
64 const float blow(preshifted*frequency);
67 float rest(blow-phase);
68 if (rest <= 0.0 && phase>0) {
80 const bool do_alter(alternate && (phase&1));
81 const float altered(do_alter ? 1.0-rest : rest);
83 #if defined(DEBUG) && 0
85 "f=%f preshifted=%f blow=%f postshifted=%f phase=%i rest=%f do_alter=%i altered=%f\n",
86 f, preshifted, blow, postshifted, phase, rest, do_alter, altered);
93 void calc_bound_results() {
94 result_lower_bound = rephase_inbound(0.0);
95 result_upper_bound = rephase_inbound(1.0);
104 result_lower_bound(0.0),
105 result_upper_bound(1.0)
108 Phaser(
float frequency_,
bool alternate_,
float preshift_,
float postshift_) :
109 frequency(frequency_),
111 postshift(postshift_),
112 alternate(alternate_)
117 calc_bound_results();
126 : rephase_inbound(f));
151 virtual ShadedValue
clone()
const = 0;
154 #if defined(UNIT_TESTS)
155 virtual const char *inspect()
const = 0;
160 static ShadedValue
make(
float f);
161 static ShadedValue
make(
float f1,
float f2);
162 static ShadedValue
make(
float f1,
float f2,
float f3);
165 virtual ShadedValue
mix(
float my_ratio,
const ValueTuple& other)
const = 0;
166 virtual ShadedValue
reverse_mix(
float ,
const class NoTuple& )
const {
return undefined_reverse_mix(); }
167 virtual ShadedValue
reverse_mix(
float ,
const class LinearTuple& )
const {
return undefined_reverse_mix(); }
168 virtual ShadedValue
reverse_mix(
float ,
const class PlanarTuple& )
const {
return undefined_reverse_mix(); }
169 virtual ShadedValue
reverse_mix(
float ,
const class SpatialTuple& )
const {
return undefined_reverse_mix(); }
175 return val1->mix(val1_ratio, *val2);
195 virtual void init_specific_awars(
AW_root *awr) = 0;
204 description(description_)
254 #define NO_PLUGIN_SELECTED ""
265 mutable int reshade_delay_level;
266 mutable bool reshade_was_suppressed;
268 void delay_reshade_callbacks(
bool suppress)
const {
269 reshade_delay_level += suppress ? 1 : -1;
272 if (!reshade_delay_level) {
273 if (reshade_was_suppressed) {
275 reshade_was_suppressed =
false;
279 #if defined(ASSERTION_USED)
280 bool start_of_delay = reshade_delay_level == 1 && suppress;
294 description(description_),
296 undefined_gc(undefined_gc_),
297 reshade_delay_level(0),
298 reshade_was_suppressed(
false),
312 virtual void init() = 0;
330 if (val->is_defined()) {
331 return first_range_gc + val->range_offset(phaser);
339 if (reshade_delay_level) reshade_was_suppressed =
true;
350 shader->delay_reshade_callbacks(
true);
353 shader->delay_reshade_callbacks(
false);
373 #error item_shader.h included twice
374 #endif // ITEM_SHADER_H
virtual bool is_defined() const =0
#define implicated(hypothesis, conclusion)
return string(buffer, length)
static ShadedValue make(float f)
bool overlay_marked() const
ShadedValue shade(GBDATA *gb_item) const
virtual char * store_config() const =0
SmartPtr< ShaderPlugin > ShaderPluginPtr
ValueTuple::ShadedValue ShadedValue
void announce_shader(ItemShader *shader)
const char * GBS_global_string(const char *templat,...)
virtual ShadedValue reverse_mix(float, const class NoTuple &) const
void init_awars(AW_root *awr, const char *awar_prefix_)
const char * get_shader_local_id() const
ItemShader * registerItemShader(AW_root *awr, AW_gc_manager *gcman, BoundItemSel &itemtype, const char *unique_id, const char *description, const char *help_id, ReshadeCallback reshade, int undef_gc)
bool overlay_marked() const
Phaser(float frequency_, bool alternate_, float preshift_, float postshift_)
virtual ShadedValue shade(GBDATA *gb_item) const =0
ShaderPlugin(const std::string &id_, const std::string &description_)
const ItemShader * shader_plugged_into() const
virtual bool activate_plugin(const std::string &id)=0
bool overlay_color_groups() const
virtual ShadedValue reverse_mix(float, const class LinearTuple &) const
bool isSet() const
test if SmartPtr is not NULp
virtual ShadedValue reverse_mix(float, const class SpatialTuple &) const
virtual bool customizable() const =0
virtual ShadedValue reverse_mix(float, const class PlanarTuple &) const
virtual int get_dimension() const =0
virtual ShadedValue mix(float my_ratio, const ValueTuple &other) const =0
virtual void check_dimension_change()=0
bool is_active_plugin(const ShaderPlugin &plugin) const
virtual int range_offset(const Phaser &) const =0
#define NO_PLUGIN_SELECTED
virtual void register_plugin(ShaderPluginPtr plugin)=0
const std::string & get_description() const
SmartPtr< ValueTuple > ShadedValue
const char * dimension_awar(int dim, const char *name) const
const char * plugin_awar(const char *name) const
virtual void load_or_reset_config(const char *cfgstr)=0
bool AW_color_groups_active()
virtual std::string active_plugin_name() const =0
void(* ReshadeCallback)()
static ShadedValue undefined()
void trigger_reshade_callback(ReshadeMode mode)
ShadedValue mix(const ShadedValue &val1, float val1_ratio, const ShadedValue &val2)
void trigger_reshade_if_active_cb(ReshadeMode mode)
DelayReshade(const ItemShader *shader_)
virtual void customize(AW_root *awr)=0
virtual ShadedValue clone() const =0
virtual void activate(bool on)=0
const std::string & get_id() const
ItemShader(const std::string &id_, const std::string &description_, ReshadeCallback rcb, int undefined_gc_)
const std::string & get_description() const
bool overlay_color_groups() const
virtual void popup_config_window(AW_root *awr)=0
const std::string & get_id() const
int to_GC(const ShadedValue &val) const
ShaderPluginPtr active_plugin
float rephase(float f) const