Greetings,
I've written a patch that lets the client use two suffixes (K and M) to
represent large experience numbers. The current implementation uses the
suffixes only when there are at least 3 significant digits.
For instance, instead of showing 30,000 as "30K" it shows it as "30000".
300,000 now shows up as "300K" instead.
This method seems to involve the least amount of work, as doing a percent
meter or the like will probably require some client layout changes. Ideas?
(patch also changes to symbolic names for update_stat(), i.e. STAT_BAR_HP)
Sincerely,
Kevin Zheng
--- gtk-v2/src/stats.c.orig 2012-03-18 01:17:47.000000000 -0500
+++ gtk-v2/src/stats.c 2012-09-18 20:08:10.000000000 -0500
@@ -409,10 +409,30 @@
gtk_widget_modify_base(stat_bar[stat_no], GTK_STATE_SELECTED, set_color);
gtk_progress_set_percentage(GTK_PROGRESS(stat_bar[stat_no]), bar);
- snprintf(buf, sizeof(buf), "%"FMT64, current_stat);
- gtk_label_set(GTK_LABEL(stat_current[stat_no]), buf);
- snprintf(buf, sizeof(buf), "%"FMT64, max_stat);
- gtk_label_set(GTK_LABEL(stat_max[stat_no]), buf);
+ if (stat_no != STAT_BAR_EXP) {
+ snprintf(buf, sizeof(buf), "%"FMT64, current_stat);
+ gtk_label_set(GTK_LABEL(stat_current[stat_no]), buf);
+ snprintf(buf, sizeof(buf), "%"FMT64, max_stat);
+ gtk_label_set(GTK_LABEL(stat_max[stat_no]), buf);
+ }
+ else {
+ int divide_factor = 1;
+ char suffix = NULL;
+
+ if (current_stat >= 1000000 * 100) {
+ divide_factor = 1000000;
+ suffix = 'M';
+ }
+ else if (current_stat >= 1000 * 100) {
+ divide_factor = 1000;
+ suffix = 'K';
+ }
+
+ snprintf(buf, sizeof(buf), "%"FMT64"%c", current_stat / divide_factor, suffix);
+ gtk_label_set(GTK_LABEL(stat_current[stat_no]), buf);
+ snprintf(buf, sizeof(buf), "%"FMT64"%c", max_stat / divide_factor, suffix);
+ gtk_label_set(GTK_LABEL(stat_max[stat_no]), buf);
+ }
}
/**
@@ -424,13 +444,13 @@
static int lastbeep=0;
static sint64 level_diff;
- update_stat(0, cpl.stats.maxhp, cpl.stats.hp,
+ update_stat(STAT_BAR_HP, cpl.stats.maxhp, cpl.stats.hp,
cpl.stats.maxhp, cpl.stats.hp, TRUE);
- update_stat(1, cpl.stats.maxsp, cpl.stats.sp,
+ update_stat(STAT_BAR_SP, cpl.stats.maxsp, cpl.stats.sp,
cpl.stats.maxsp, cpl.stats.sp, TRUE);
- update_stat(2, cpl.stats.maxgrace, cpl.stats.grace,
+ update_stat(STAT_BAR_GRACE, cpl.stats.maxgrace, cpl.stats.grace,
cpl.stats.maxgrace, cpl.stats.grace, TRUE);
- update_stat(3, 999, cpl.stats.food, 999, cpl.stats.food, TRUE);
+ update_stat(STAT_BAR_FOOD, 999, cpl.stats.food, 999, cpl.stats.food, TRUE);
/* We may or may not have an exp table from the server. If we don't, just
* use current exp value so it will always appear maxed out.
@@ -443,7 +463,7 @@
else
level_diff=cpl.stats.exp;
- update_stat(4,
+ update_stat(STAT_BAR_EXP,
(cpl.stats.level+1) < exp_table_max ? exp_table[cpl.stats.level+1]:cpl.stats.exp,
cpl.stats.exp,
level_diff,
_______________________________________________
crossfire mailing list
[email protected]
http://mailman.metalforge.org/mailman/listinfo/crossfire