Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

War1gus fix #590

Merged
merged 2 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/include/movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class Movie : public gcn::SDLImage
bool Load(const std::string &filename, int w, int h);
bool IsPlaying() const { return true; }

// guichan
SDL_Surface *getSurface() const override;

public:
CFile *f = nullptr;
mutable bool need_data = true;
Expand Down
6 changes: 5 additions & 1 deletion src/include/unittype.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,11 @@ class CBuildRestrictionDistance : public CBuildRestriction
public:
CBuildRestrictionDistance() = default;

void Init() override {this->RestrictType = &UnitTypeByIdent(this->RestrictTypeName);}
void Init() override
{
this->RestrictType =
this->RestrictTypeName.empty() ? nullptr : &UnitTypeByIdent(this->RestrictTypeName);
}
bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const override;

int Distance = 0; /// distance to build (circle)
Expand Down
3 changes: 3 additions & 0 deletions src/ui/icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ bool IconConfig::LoadNoLog()
*/
bool IconConfig::Load()
{
if (this->Name.empty()) {
return false;
}
if (LoadNoLog() == true) {
ShowLoadProgress(_("Icon %s"), this->Name.c_str());
return true;
Expand Down
4 changes: 4 additions & 0 deletions src/ui/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ CImageButton::CImageButton(const std::string &caption) :
void CImageButton::draw(gcn::Graphics *graphics) /* override */
{
if (!normalImage) {
if (this->getBackgroundColor().a == 0) {
return;
}

Button::draw(graphics);
return;
}
Expand Down
50 changes: 50 additions & 0 deletions src/video/movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,56 @@ bool Movie::Load(const std::string &name, int w, int h)
return true;
}

SDL_Surface *Movie::getSurface() const /* override */
{
if (data == nullptr) {
data = (OggData *) calloc(sizeof(OggData), 1);
if (OggInit(f, data) || !data->video) {
OggFree(data);
f->close();
ErrorPrint("Could not init OggData or not a video\n");
return mSurface;
}

data->File = f;
yuv_overlay = SDL_CreateTexture(TheRenderer,
SDL_PIXELFORMAT_YV12,
SDL_TEXTUREACCESS_STREAMING,
data->tinfo.frame_width,
data->tinfo.frame_height);

if (yuv_overlay == nullptr) {
ErrorPrint("SDL_CreateYUVOverlay: %s\n", SDL_GetError());
ErrorPrint(
"SDL_CreateYUVOverlay: %dx%d\n", data->tinfo.frame_width, data->tinfo.frame_height);
OggFree(data);
f->close();
return mSurface;
}

start_time = SDL_GetTicks();
need_data = true;
TheoraProcessData(data);
RenderToSurface(mSurface, yuv_overlay, rect, data);
}
if (need_data) {
if (TheoraProcessData(data)) {
return mSurface;
}
need_data = false;
}

const int diff =
SDL_GetTicks() - start_time
- static_cast<int>(theora_granule_time(&data->tstate, data->tstate.granulepos) * 1000);

if (diff > 0) {
RenderToSurface(mSurface, yuv_overlay, rect, data);
need_data = true;
}
return mSurface;
}

#else

#include <string>
Expand Down