mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
first stab at a group level margin override
This commit is contained in:
parent
5d4bd04eab
commit
3c864d6a2a
@ -119,6 +119,37 @@ get_groups() const {
|
|||||||
return _dependent;
|
return _dependent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PaletteGroup::get_margin_override
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the set of groups this group depends on.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
int PaletteGroup::
|
||||||
|
get_margin_override() const {
|
||||||
|
return _margin_override;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PaletteGroup::get_margin_override
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the set of groups this group depends on.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PaletteGroup::
|
||||||
|
set_margin_override(const int override) {
|
||||||
|
_margin_override = override;
|
||||||
|
_has_margin_override = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PaletteGroup::has_margin_override
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the set of groups this group depends on.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool PaletteGroup::
|
||||||
|
has_margin_override() const {
|
||||||
|
return _has_margin_override;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PaletteGroup::get_placements
|
// Function: PaletteGroup::get_placements
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -65,6 +65,10 @@ public:
|
|||||||
int get_dependency_order() const;
|
int get_dependency_order() const;
|
||||||
int get_dirname_order() const;
|
int get_dirname_order() const;
|
||||||
|
|
||||||
|
void set_margin_override(const int override);
|
||||||
|
int get_margin_override() const;
|
||||||
|
bool has_margin_override() const;
|
||||||
|
|
||||||
bool is_preferred_over(const PaletteGroup &other) const;
|
bool is_preferred_over(const PaletteGroup &other) const;
|
||||||
|
|
||||||
void increment_egg_count();
|
void increment_egg_count();
|
||||||
@ -116,6 +120,8 @@ private:
|
|||||||
// don't use them otherwise.
|
// don't use them otherwise.
|
||||||
int _num_placements;
|
int _num_placements;
|
||||||
int _num_pages;
|
int _num_pages;
|
||||||
|
bool _has_margin_override;
|
||||||
|
int _margin_override;
|
||||||
pvector<PalettePage *> _load_pages;
|
pvector<PalettePage *> _load_pages;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -939,7 +939,11 @@ compute_size_from_uvs(const TexCoordd &min_uv, const TexCoordd &max_uv) {
|
|||||||
_position._x_size = max(_position._x_size, 4);
|
_position._x_size = max(_position._x_size, 4);
|
||||||
_position._y_size = max(_position._y_size, 4);
|
_position._y_size = max(_position._y_size, 4);
|
||||||
|
|
||||||
_position._margin = _texture->get_margin();
|
if(get_group()->has_margin_override()) {
|
||||||
|
_position._margin = get_group()->get_margin_override();
|
||||||
|
} else {
|
||||||
|
_position._margin = _texture->get_margin();
|
||||||
|
}
|
||||||
//cout << "margin: " << _position._margin << endl;
|
//cout << "margin: " << _position._margin << endl;
|
||||||
|
|
||||||
// Normally, we have interior margins, but if the image size is too
|
// Normally, we have interior margins, but if the image size is too
|
||||||
|
@ -128,6 +128,8 @@ private:
|
|||||||
// don't use it otherwise.
|
// don't use it otherwise.
|
||||||
int _num_references;
|
int _num_references;
|
||||||
|
|
||||||
|
int _margin_override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -228,6 +228,7 @@ parse_group_line(const vector_string &words) {
|
|||||||
S_on,
|
S_on,
|
||||||
S_includes,
|
S_includes,
|
||||||
S_dir,
|
S_dir,
|
||||||
|
S_margin,
|
||||||
};
|
};
|
||||||
State state = S_none;
|
State state = S_none;
|
||||||
|
|
||||||
@ -248,6 +249,9 @@ parse_group_line(const vector_string &words) {
|
|||||||
} else if (word == "dir") {
|
} else if (word == "dir") {
|
||||||
state = S_dir;
|
state = S_dir;
|
||||||
|
|
||||||
|
} else if (word == "margin") {
|
||||||
|
state = S_margin;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case S_none:
|
case S_none:
|
||||||
@ -275,7 +279,16 @@ parse_group_line(const vector_string &words) {
|
|||||||
group->set_dirname(word);
|
group->set_dirname(word);
|
||||||
state = S_none;
|
state = S_none;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case S_margin:
|
||||||
|
int margin_override;
|
||||||
|
if (!string_to_int(word, margin_override)) {
|
||||||
|
group->set_margin_override(margin_override);
|
||||||
|
}
|
||||||
|
state = S_none;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++wi;
|
++wi;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user