Page 2 of 3

Re: ManiaControl Promotion plugin

Posted: 04 Jul 2014, 13:19
by chco
No, I get that and much appreciated! :)

Re: ManiaControl Promotion plugin

Posted: 08 Jul 2014, 02:29
by steeffeen
i kinda doubt that "self::.." will work, you might need to use the class name directly

my attempt:

Code: Select all

const SETTING_PROMOTE = 'Message text ';
// ..
for (int i = 0; i < self::MESSAGE_COUNT; i++) {
	$settingName = self::SETTING_PROMOTE . $i;
	$settingValue = $this->maniaControl->settingManager->getSettingValue($settingName);
	if ($settingValue) {
		array_push($this->message, $settingValue);
	}
}
or if you like fewer lines

Code: Select all

// ..
for (int i = 0; i < self::MESSAGE_COUNT; i++) {
	if ($settingValue = $this->maniaControl->settingManager->getSettingValue(self::SETTING_PROMOTE . $i)) {
		array_push($this->message, $settingValue);
	}
}
>> not tested
note the single get() instead of two calls

(setting names have numbers instead of characters that way though, which scales better anyways)

Re: ManiaControl Promotion plugin

Posted: 08 Jul 2014, 07:08
by chco
Thanks for the examples guys!
Btw, the reason it didn't have numbers is the fact that in the settings screen of mc you get:
Setting 1
Setting 10
Setting 2
Setting 3

That is why I used a, b,c...
I'll try out your suggestions gentlemen.
Thanks!

Re: ManiaControl Promotion plugin

Posted: 08 Jul 2014, 09:01
by steeffeen
kremsy wrote:The Numbers in Steeffeens example are only for accassing the Settings (they have nothing todo with the displayed names).
that's not correct ^^
the numbers are part of the message
chco wrote:That is why I used a, b,c...
you're right there, that comes from the alphabetical ordering
either you format the numbers to look like 01, 02, .., 11, ..
or simply use chr() to get the characters from the loop counter
(A = 65, B = 66, ..)

Code: Select all

$x = chr(65 + $i);

Re: ManiaControl Promotion plugin

Posted: 05 Aug 2014, 17:35
by steeffeen
please fix the errors of the plugin, check out http://maniacontrol.com/user/errors

Re: ManiaControl Promotion plugin

Posted: 06 Aug 2014, 15:00
by chco
I've passed one on to you guys (when settings are changed part) as I cannot reproduce this error.
New version (1.2) is uploaded..

Sorry it took a while, was away much.

Re: ManiaControl Promotion plugin

Posted: 06 Aug 2014, 15:23
by steeffeen
chco wrote:I've passed one on to you guys (when settings are changed part) as I cannot reproduce this error.

Code: Select all

public function handleSettingChangedCallback(Setting $setting)
you have to add a use statement for the settings namespace