2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2016-05-09 21:51:30 +00:00
|
|
|
package net.minecraftforge.client.event;
|
|
|
|
|
2018-11-29 06:15:05 +00:00
|
|
|
import net.minecraft.client.renderer.texture.NativeImage;
|
2016-05-09 21:51:30 +00:00
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
|
import net.minecraft.util.text.TextComponentString;
|
2018-06-11 01:12:46 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Cancelable;
|
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
2016-05-09 21:51:30 +00:00
|
|
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This event is fired before and after a screenshot is taken
|
|
|
|
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
|
|
|
|
* This event is {@link Cancelable}
|
|
|
|
*
|
|
|
|
* {@link #screenshotFile} contains the file the screenshot will be/was saved to
|
|
|
|
* {@link #image} contains the {@link BufferedImage} that will be saved
|
|
|
|
* {@link #resultMessage} contains the {@link ITextComponent} to be returned. If {@code null}, the default vanilla message will be used instead
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2018-11-29 06:15:05 +00:00
|
|
|
public class ScreenshotEvent extends Event
|
2016-05-09 21:51:30 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public static final ITextComponent DEFAULT_CANCEL_REASON = new TextComponentString("Screenshot canceled");
|
|
|
|
|
2018-11-29 06:15:05 +00:00
|
|
|
private NativeImage image;
|
2016-05-09 21:51:30 +00:00
|
|
|
private File screenshotFile;
|
|
|
|
|
|
|
|
private ITextComponent resultMessage = null;
|
|
|
|
|
2018-11-29 06:15:05 +00:00
|
|
|
public ScreenshotEvent(NativeImage image, File screenshotFile)
|
2016-05-09 21:51:30 +00:00
|
|
|
{
|
|
|
|
this.image = image;
|
|
|
|
this.screenshotFile = screenshotFile;
|
|
|
|
}
|
|
|
|
|
2018-11-29 06:15:05 +00:00
|
|
|
public NativeImage getImage()
|
2016-05-09 21:51:30 +00:00
|
|
|
{
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
public File getScreenshotFile()
|
|
|
|
{
|
|
|
|
return screenshotFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setScreenshotFile(File screenshotFile)
|
|
|
|
{
|
|
|
|
this.screenshotFile = screenshotFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ITextComponent getResultMessage()
|
|
|
|
{
|
|
|
|
return resultMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setResultMessage(ITextComponent resultMessage)
|
|
|
|
{
|
|
|
|
this.resultMessage = resultMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ITextComponent getCancelMessage()
|
|
|
|
{
|
|
|
|
return getResultMessage() != null ? getResultMessage() : DEFAULT_CANCEL_REASON;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|