Logo

[SM5] The Banner display code problem

Register Log In Back To Forums

Post #1 · Posted at 2014-02-08 03:31:39pm 10.1 years ago

Offline zGHRs
zGHRs Avatar Member
36 Posts
China
Reg. 2013-07-01


Last updated: 2014-02-09 07:51am
Now I have got a question, I have made the code for displaying the banner. I have made the different banner zoom height size due to the different banner from random size. I have written for these codes of below, however, The code can display the zoomwidth instead of the zoomheight (zoomheight display failed). It already telling for error playing command. Please let me to see what the problem of the code?

The displaying code:
Quote

local r=Def.ActorFrame{};
local JamNgok = GAMESTATE:GetCurrentSong();
local JACKET = JamNgok:GetJacketPath();
local BANNER = JamNgok:GetBannerPath();

local function BannerHeight()
(This place was always told the error playing command no matter when I have added or removed for the code about "local BNfgd = self:GetChild("Banner")", and also "local function BannerHeight(self)", "self" this word have removed or not.)
local w_MAX = BNfgd:GetWidth();
local h_MAX = BNfgd:GetHeight();
local average = w_MAX/h_MAX;
if average > 3.18 and average < 3.22 then
return 40;
elseif average > 2.54 and average < 2.58 then
return 50;
else
return 128/average;
end;
end;

if JamNgok:HasJacket() then
r[#r+1] = LoadActor(JACKET)..
{
InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_TOP+25;shadowlength,1;zoomtowidth,64;zoomtoheight,64);
};
elseif JamNgok:HasBanner() then
r[#r+1] = LoadActor(BANNER)..
{
InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_TOP+25;shadowlength,1;zoomtowidth,128;zoomtoheight,BannerHeight());
};
else
r[#r+1]=Def.ActorFrame{};
end;

return r;

Post #2 · Posted at 2014-02-09 03:02:53pm 10.1 years ago

Offline dbk2
dbk2 Avatar Member
332 Posts
Not Set
Reg. 2012-04-30

In your function, BannerHeight(), you have a variable BNfgd but you don't declare that variable anywhere in that code.

I see that you have a note about:
local BNfgd = self:GetChild("Banner")

but self has no context in that function, either.

One way to load a banner is...

Quote

Def.Sprite{
OnCommand=function(self)
local song, path;
song = GAMESTATE:GetCurrentSong();

if song then
path = song:GetBannerPath();
end;

if path then
self:Load(path);
end;
end;
};

Post #3 · Posted at 2014-02-09 04:32:56pm 10.1 years ago

Offline zGHRs
zGHRs Avatar Member
36 Posts
China
Reg. 2013-07-01


Last updated: 2014-02-09 04:34pm
Quote: dbk2
In your function, BannerHeight(), you have a variable BNfgd but you don't declare that variable anywhere in that code.

I see that you have a note about:
local BNfgd = self:GetChild("Banner")

but self has no context in that function, either.

One way to load a banner is...

Quote

Def.Sprite{
OnCommand=function(self)
local song, path;
song = GAMESTATE:GetCurrentSong();

if song then
path = song:GetBannerPath();
end;

if path then
self:Load(path);
end;
end;
};

And I have got a question, How to get the banner width or banner height? I want to display the different banner size due to the different banner size, and then to resize to the same width and the different height. Why I have used for song:GetWidth() or song:GetHeight() this function. It told the error playing command for " attempt to call method 'GetWidth' or 'GetHeight' "? Obviously these codes are variable from http://kki.ajworld.net/lua/sm5/Lua.xml#ActorFrame (See also "Class Actor" that place).

Post #4 · Posted at 2014-02-10 05:26:16am 10.1 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"
Maybe I am saying something different but...

On my Current Theme I'm making, on the ScreenSelectMusic, I got that the Banner of each song appears of differents sizes obviously because some songs has a different size... The thing that I do for make all the banners with the same size was a little code on the metrics.ini

That fixed the problem for ME, I don't know if you need a different code, My code is via Metrics.ini:

BannerX=SCREEN_CENTER_X+124
BannerY=SCREEN_CENTER_Y+180
BannerOnCommand=draworder,-1;scaletoclipped,590,185;zoom,0.3
BannerOffCommand=bouncebegin,0.15;zoomx,0;

The code I used was scaletoclipped,590,185 it force the size that you want width x height. In LUA coding I have nothing, I dont know if it help at least In something.
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #5 · Posted at 2014-02-10 09:51:59am 10.1 years ago

Offline dbk2
dbk2 Avatar Member
332 Posts
Not Set
Reg. 2012-04-30


Last updated: 2014-02-11 01:56am
This example demonstrates how to get the height and width a banner (or any image): http://pastebin.com/nuyh7DCd

Once you have the height and width, you can do use math and conditional logic, as in your original post to calculate how you want to resize things.

I'll mention that there is this page which lists many of the sizing methods available for Sprite objects in StepMania 5: http://kki.ajworld.net/wiki/Commands:Size_commands

There is also a method which I use for banners, setsize()

Here is a quick example:
I want ALL my banners to be 418x164. After using load() (like in the pastebin example), I would do:

Quote
self:setsize(418,164);

Hopes this helps.

Post #6 · Posted at 2014-02-26 06:38:16am 10 years ago

Offline zGHRs
zGHRs Avatar Member
36 Posts
China
Reg. 2013-07-01


Last updated: 2014-02-26 06:39am
Thanks for dbk2 offered for codes, Now the song banner code can run it. However, I have got a new question.
Expect the song or course banners, It can't be displayed for song group banner or the roulette banner.
like the code of below:

Quote

SetCommand=function(self, params)
self:stoptweening();
local SOC;
if GAMESTATE:GetCurrentCourse() then
SOC=GAMESTATE:GetCurrentCourse();
elseif GAMESTATE:GetCurrentSong() then
SOC=GAMESTATE:GetCurrentSong();
end;
if SOC then
if not GAMESTATE:IsCourseMode() then
if SOC:HasBanner() then
self:LoadBackground(GetSongOrCourseBannerPath(SOC));
elseif SONGMANBig GrinoesSongGroupExist(params.Song:GetGroupName()) then
self:LoadBackground(GetSongGroupBannerPath(params.Song:GetGroupName()));
elseif params.WheelBase:GetSelectedType() == 'WheelItemDataType_Roulette' then
self:Load(THEME:GetPathG("Banner","Roulette"));
elseif params.WheelBase:GetSelectedType() == 'WheelItemDataType_Random' then
self:Load(THEME:GetPathG("Banner","Random"));
else
self:Load(THEME:GetPathG("Common fallback","banner"));
end;
end;
end;
end;

I want to ask a question: Does this code have got problems for displaying the song group banner or roulette banner?

Post #7 · Posted at 2014-02-26 08:38:30am 10 years ago

Offline dbk2
dbk2 Avatar Member
332 Posts
Not Set
Reg. 2012-04-30

The code you posted above has a few errors. I can help you with these errors, but I think it might be better if you describe as clearly as possible what you are trying to accomplish. That way, I can help decide if there is a different, better way to do whatever you're trying to do.

Post #8 · Posted at 2014-02-28 01:52:40pm 10 years ago

Offline zGHRs
zGHRs Avatar Member
36 Posts
China
Reg. 2013-07-01


Last updated: 2014-02-28 01:54pm
Quote: dbk2
The code you posted above has a few errors.
It seems that you don't understand for my meaning. My meaning: From (Post #1) to (Post #5) for displaying on other screen display [NOT in the ScreenSelectMusic], and then that code problem had solved. However, (Post #6) is for the ScreenSelectMusic interface. There are both not the same.

Post #9 · Posted at 2014-03-01 11:50:08am 10 years ago

Offline dbk2
dbk2 Avatar Member
332 Posts
Not Set
Reg. 2012-04-30


Last updated: 2014-03-01 11:50am
This is what I'm doing in my theme. Most of this is inspired by freem's code in his Moonlight theme.

In Metrics.ini, I hide the banner.

Quote
[ScreenSelectMusic]
BannerX=0
BannerY=0
BannerOnCommand=scaletoclipped,418,164;visible,false

In /BGAnimations/ScreenSelectMusic overlay.lua I use an ActorProxy in conjunction with SCREENMAN:GetTopScreen():GetChild('Banner')

You can see my code here: http://pastebin.com/BbEFP1pg

Post #10 · Posted at 2014-03-02 02:47:23pm 10 years ago

Offline zGHRs
zGHRs Avatar Member
36 Posts
China
Reg. 2013-07-01

And then I have got the question:

I have written the banner code displayed for like this (see the quote):
Quote

Def.ActorProxy
{
Name="BannerProxy";
BeginCommand=function(self)
local WF = SCREENMAN:GetTopScreen():GetChild('Banner');
local CDou, FDou, PGwan;
CDou = WF:GetWidth();
FDou = WF:GetHeight();
PGwan = CDou/FDou;
if PGwan > 3.17 and PGwan < 3.23 then
WF:scaletoclipped(256,80);
elseif PGwan > 2.53 and PGwan < 2.59 then
WF:scaletoclipped(204.8,80);
else
WF:scaletoclipped(256,80);
end;
selfConfusedetTarget(WF);
end;
};
I want to made this code displayed the different size of banner on ScreenSelectMusic (That was inspired by freem's code in his Moonlight theme). However, a problem just come, There just doesn't display for the different banner sizes. And then how to fix it?
However,

Post #11 · Posted at 2014-03-03 09:23:38am 10 years ago

Offline dbk2
dbk2 Avatar Member
332 Posts
Not Set
Reg. 2012-04-30

So you want banners that are different sizes to appear differently on ScreenSelectMusic? (I am only confused because I have never seen any other theme do this.)

The line from my Metrics sets the size of the banner: BannerOnCommand=scaletoclipped,418,164;visible,false

If do not specify a height and width in Metrics like BannerOnCommand=visible,false then differently-sized banners will display with their native sizes on ScreenSelectMusic.

Is that what you are trying to do?

Post #12 · Posted at 2014-03-04 06:35:37am 10 years ago

Offline zGHRs
zGHRs Avatar Member
36 Posts
China
Reg. 2013-07-01


Last updated: 2014-03-04 09:01am
Quote: dbk2
So you want banners that are different sizes to appear differently on ScreenSelectMusic? (I am only confused because I have never seen any other theme do this.)

Now you have to go and check it out the theme, D3NEX. that theme had made the banners that are different sizes to appear differently on ScreenSelectMusic.

Quote: dbk2

If do not specify a height and width in Metrics like BannerOnCommand=visible,false then differently-sized banners will display with their native sizes on ScreenSelectMusic.

I have written the code like Post #10, however, it doesn't display for the banners that are different sizes to appear differently. (like the photo of below, No matter how specified a height and width in Metrics like BannerOnCommand=visible,false or not)
http://i482.photobucket.com/albums/rr190/HUGO_FUKT/2014-03-04_061949.jpg
It just told an error command:
WARNING: Error playing command: /Themes/***/BGAnimations/ScreenSelectMusic decorations/default.lua:36: attempt to compare number with nil

Quote: dbk2
Is that what you are trying to do?
Yes, that was for my new trying.

Post #13 · Posted at 2014-03-05 01:28:27pm 10 years ago

Offline dbk2
dbk2 Avatar Member
332 Posts
Not Set
Reg. 2012-04-30

I understand the problem you're experiencing now (sort of). I've tried to document/explain some of it here:
http://pastebin.com/tVDXnELm

It seems that you can't GetWidth() and GetHeight() on ActorProxies. Or, rather, you can, but the height and width values returned are always 1 so it's not helpful. I'm not sure if this is a StepMania bug (possible), or whether I don't understand ActorProxies properly (also possible).

Anyway, maybe you can combine your Lua from post #6 and #10. I'm thinking you can work within the SetCommand. Use the Lua from post #6 to get the height and width of the current SongOrCourse, and then use that knowledge to scale the ActorProxy appropriately.

It's late and I haven't actually tried that, so it might not work...

Post #14 · Posted at 2014-03-06 01:09:18am 10 years ago

Offline Mad Matt
Mad Matt Avatar Member
65 Posts
United States
Reg. 2011-10-26


Last updated: 2014-03-06 01:10am
Quote: dbk2
It seems that you can't GetWidth() and GetHeight() on ActorProxies. Or, rather, you can, but the height and width values returned are always 1 so it's not helpful. I'm not sure if this is a StepMania bug (possible), or whether I don't understand ActorProxies properly (also possible).

Very Basic:
ActorProxies can be thought of like a weaker version of an ActorFrame. Any position, rotation, or zoom change you make the the ActorProxy will be applied on top of the values for it's Target, but will not replace the values of the Target. I saw "weaker" because other changes like diffuse are not applied.

More in depth:
It all revolves around the function Actor::Draw()

At the very beginning of the function, if an actor is not visible, or if it is hibernating, it aborts early and the actor is not drawn.

The draw cycle for an actor involves 4 parts

PreDraw: This applies the temporary changes from effects( diffuseblink, glowshift, bob, etc ). This is done by all Actor Classes.

If, after PreDraw, the actor's alpha values are 0, it will not process the following 3 steps.

BeginDraw: This sets the position, rotation, zoom, and skew of the display, based on the values set for the Actor. The only Actor Class with a derived version of this function is ActorFrame, runs Actor::BeingDraw() and then sets FOV and lighting values.

DrawPrimitives: This is where the magic happens. Each Actor Class has it's own DrawPrimitives function that determines how it's drawn. For ActorFrames, this function executes the Draw function on all of their children. BitmapTexts will assemble and draw their characters, Sprites draw their textures. ActorProxies make their target visible, draw their target, and then restore the original visibility value to their target.

EndDraw: This pops this display, removing any changes set by BeginDraw. The only Actor Class with a derived version of this function is ActorFrame, runs Actor::EndDraw() and undoes the other changes it made during BeginDraw.

So, with regards to the ActorProxy height and width issue, the height and width of the proxy itself are only meaningful as scale factors applied to the target's own scaled height and width.

I used ActorProxies breifly myself, but eventually abandoned them in favor of the more powerful ( and more dangerous ) ActorFrame:SetDrawFunction() + Actor:Draw()

Post #15 · Posted at 2014-03-07 06:52:02am 10 years ago

Offline zGHRs
zGHRs Avatar Member
36 Posts
China
Reg. 2013-07-01

I haven't found that codes like PreDraw, BeginDraw, DrawPrimitives, and EndDraw in stepmania 5 lua information page. Where can you find it, Mad Matt?

Post #16 · Posted at 2014-03-07 11:30:49am 10 years ago

Offline Mad Matt
Mad Matt Avatar Member
65 Posts
United States
Reg. 2011-10-26

Quote: zGHRs
I haven't found that codes like PreDraw, BeginDraw, DrawPrimitives, and EndDraw in stepmania 5 lua information page. Where can you find it, Mad Matt?

Those are C++ functions in the source code, not lua functions directly accessible to a theme.
Register Log In Back To Forums

0 User(s) Viewing This Thread (Past 15 Minutes)

©2006-2024 Zenius -I- vanisher.com -5th style- IIPrivacy Policy
Web Server: 5% · Database: 8% · Server Time: 2024-03-28 11:51:47
This page took 0.012 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language