forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request godotengine#16 from ramatakinc/feature/3.x-ads-aut…
…o_install_template Add advertisement modules and core scaffolding
- Loading branch information
Showing
53 changed files
with
2,372 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env python | ||
|
||
Import("env") | ||
|
||
env_templates = env.Clone() | ||
|
||
env_templates.add_source_files(env.core_sources, "*.cpp") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "monetization_settings.h" | ||
#include "core/project_settings.h" | ||
|
||
MonetizationSettings *MonetizationSettings::singleton = nullptr; | ||
|
||
MonetizationSettings::MonetizationSettings() { | ||
singleton = this; | ||
} | ||
|
||
MonetizationSettings::~MonetizationSettings() { | ||
} | ||
|
||
MonetizationSettings *MonetizationSettings::get_singleton() { | ||
return singleton; | ||
} | ||
|
||
void MonetizationSettings::_bind_methods() { | ||
ClassDB::bind_method(D_METHOD("delete_ad_unit", "ad_unit"), &MonetizationSettings::delete_ad_unit); | ||
ClassDB::bind_method(D_METHOD("set_ad_unit_network_id", "ad_unit", "network", "network_specific_id"), &MonetizationSettings::set_ad_unit_network_id); | ||
ClassDB::bind_method(D_METHOD("get_ad_unit_network_id", "ad_unit", "network"), &MonetizationSettings::get_ad_unit_network_id); | ||
ClassDB::bind_method(D_METHOD("get_ad_units"), &MonetizationSettings::get_ad_units); | ||
} | ||
|
||
void MonetizationSettings::delete_ad_unit(StringName p_ad_unit) { | ||
String ad_unit_setting = "ramatak/monetization/ad_units"; | ||
ProjectSettings *project_settings = ProjectSettings::get_singleton(); | ||
|
||
Dictionary dict = project_settings->get(ad_unit_setting); | ||
Dictionary ad_unit_ids = dict.get(p_ad_unit, Dictionary()); | ||
ad_unit_ids.erase(p_ad_unit); | ||
dict[p_ad_unit] = ad_unit_ids; | ||
project_settings->set(ad_unit_setting, dict); | ||
} | ||
|
||
Array MonetizationSettings::get_ad_units() const { | ||
return ad_units; | ||
} | ||
|
||
String MonetizationSettings::get_ad_unit_network_id(StringName p_ad_unit, String p_network) { | ||
String ad_unit_setting = "ramatak/monetization/ad_units"; | ||
ProjectSettings *project_settings = ProjectSettings::get_singleton(); | ||
|
||
Dictionary dict = project_settings->get(ad_unit_setting); | ||
Dictionary ad_unit_ids = dict[p_ad_unit]; | ||
return ad_unit_ids.get(p_network, ""); | ||
} | ||
|
||
void MonetizationSettings::set_ad_unit_network_id(StringName p_ad_unit, String p_network, String p_id) { | ||
String ad_unit_setting = "ramatak/monetization/ad_units"; | ||
ProjectSettings *project_settings = ProjectSettings::get_singleton(); | ||
|
||
Dictionary dict = project_settings->get(ad_unit_setting); | ||
Dictionary ad_unit_ids = dict.get(p_ad_unit, Dictionary()); | ||
ad_unit_ids[p_network] = p_id; | ||
dict[p_ad_unit] = ad_unit_ids; | ||
project_settings->set(ad_unit_setting, dict); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef _MONETIZATION_SETTINGS_H | ||
#define _MONETIZATION_SETTINGS_H | ||
|
||
#include "core/class_db.h" | ||
#include "core/object.h" | ||
#include "servers/ramatak/ad_server.h" | ||
|
||
class MonetizationSettings : public Object { | ||
GDCLASS(MonetizationSettings, Object); | ||
|
||
Array ad_units; | ||
|
||
static MonetizationSettings *singleton; | ||
|
||
protected: | ||
static void _bind_methods(); | ||
|
||
public: | ||
static MonetizationSettings *get_singleton(); | ||
|
||
void delete_ad_unit(StringName p_ad_unit); | ||
|
||
void set_ad_unit_network_id(StringName p_ad_unit, String p_network, String p_id); | ||
String get_ad_unit_network_id(StringName p_ad_unit, String p_network); | ||
|
||
Array get_ad_units() const; | ||
|
||
MonetizationSettings(); | ||
virtual ~MonetizationSettings(); | ||
}; | ||
|
||
#endif // _MONETIZATION_SETTINGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="AdController" inherits="Node" version="3.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> | ||
<brief_description> | ||
Controls and configures non-banner ads like interstitials | ||
</brief_description> | ||
<description> | ||
AdController is used to set up, display, and monitor the status of an interstitial or rewarded interstitial advertisement. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
<method name="hide"> | ||
<return type="void" /> | ||
<description> | ||
Hides this advertisement. | ||
</description> | ||
</method> | ||
<method name="show"> | ||
<return type="void" /> | ||
<description> | ||
Shows this advertisement. | ||
</description> | ||
</method> | ||
</methods> | ||
<members> | ||
<member name="ad_unit" type="String" setter="set_ad_unit" getter="get_ad_unit" default=""""> | ||
The ad unit associated with this advertisement. | ||
This is used to provide the selected ad network with the information it needs to configure your advertisement and ensure revenue is appropriately handled. | ||
</member> | ||
</members> | ||
<signals> | ||
<signal name="ad_clicked"> | ||
<description> | ||
Emitted whenever the advertisement is clicked. | ||
Due to platform-specific quirks, this may not be emitted until after the user returns to the app. | ||
</description> | ||
</signal> | ||
<signal name="ad_closed"> | ||
<description> | ||
The user closed the ad. | ||
</description> | ||
</signal> | ||
<signal name="ad_error"> | ||
<argument index="0" name="message" type="String" /> | ||
<description> | ||
There was an error during the loading or display of this advertisement. | ||
The message argument provides more information about the error. | ||
</description> | ||
</signal> | ||
<signal name="ad_loaded"> | ||
<description> | ||
The advertisement has loaded. This does not indicate that it has been shown to the user. | ||
</description> | ||
</signal> | ||
<signal name="ad_reward_earned"> | ||
<description> | ||
For rewarded interstitial ads, this signal indicates that the reward is earned. | ||
Handling this signal is mandatory to comply with advertisement network guidelines. | ||
</description> | ||
</signal> | ||
<signal name="ad_shown"> | ||
<description> | ||
The advertisement has been displayed to the user. | ||
</description> | ||
</signal> | ||
</signals> | ||
<constants> | ||
</constants> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="AdServer" inherits="Object" version="3.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> | ||
<brief_description> | ||
The AdServer is a low-level interface with the Ramtak Mobile Studio advertisement system. | ||
</brief_description> | ||
<description> | ||
While it is possible to use AdServer as a user, it's much more ergonomic to use the AdController and BannerAdController nodes. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
<method name="get_available_plugins" qualifiers="const"> | ||
<return type="Array" /> | ||
<description> | ||
Regurns a list of available plugins in the current build. | ||
</description> | ||
</method> | ||
<method name="get_plugin_priority_order" qualifiers="const"> | ||
<return type="Array" /> | ||
<description> | ||
Returns the current priority order of advertisement plugins. | ||
</description> | ||
</method> | ||
<method name="set_plugin_priority_order"> | ||
<return type="void" /> | ||
<argument index="0" name="priorities" type="Array" /> | ||
<description> | ||
Sets the priority order of advertisement plugins. | ||
</description> | ||
</method> | ||
</methods> | ||
<signals> | ||
<signal name="ad_clicked"> | ||
<argument index="0" name="request_id" type="int" /> | ||
<description> | ||
Emitted whenever an advertisement is clicked. You probobaly want to be using the AdController/BannerAdController version of this signal. | ||
</description> | ||
</signal> | ||
<signal name="ad_closed"> | ||
<argument index="0" name="request_id" type="int" /> | ||
<description> | ||
Emitted whenever an advertisement is closed. You probobaly want to be using the AdController/BannerAdController version of this signal. | ||
</description> | ||
</signal> | ||
<signal name="ad_error"> | ||
<argument index="0" name="request_id" type="int" /> | ||
<argument index="1" name="message" type="String" /> | ||
<description> | ||
Emitted whenever an advertisement has an error. You probobaly want to be using the AdController/BannerAdController version of this signal. | ||
</description> | ||
</signal> | ||
<signal name="ad_loaded"> | ||
<argument index="0" name="request_id" type="int" /> | ||
<description> | ||
Emitted whenever an advertisement is loaded. You probobaly want to be using the AdController/BannerAdController version of this signal. | ||
</description> | ||
</signal> | ||
<signal name="ad_reward_earned"> | ||
<argument index="0" name="request_id" type="int" /> | ||
<description> | ||
Emitted whenever an advertisement reward is earned by the user. You probobaly want to be using the AdController/BannerAdController version of this signal. | ||
</description> | ||
</signal> | ||
<signal name="ad_shown"> | ||
<argument index="0" name="request_id" type="int" /> | ||
<description> | ||
Emitted whenever an advertisement is shown. You probobaly want to be using the AdController/BannerAdController version of this signal. | ||
</description> | ||
</signal> | ||
</signals> | ||
<constants> | ||
<constant name="AdType::AD_TYPE_BANNER" value="0" enum="AdType"> | ||
Indicates a banner ad type. | ||
</constant> | ||
<constant name="AdType::AD_TYPE_INTERSTITIAL" value="1" enum="AdType"> | ||
Indicates an interstitial ad type. | ||
</constant> | ||
<constant name="AdType::AD_TYPE_REWARDED" value="2" enum="AdType"> | ||
Indicates a rewarded interstitial ad type. | ||
</constant> | ||
<constant name="BannerAdSize::BANNER_SIZE_SMALL" value="0" enum="BannerAdSize"> | ||
Indicates a small banner size. | ||
</constant> | ||
<constant name="BannerAdSize::BANNER_SIZE_LARGE" value="1" enum="BannerAdSize"> | ||
Indicates a large banner size. | ||
</constant> | ||
<constant name="BannerAdLocation::BANNER_LOCATION_BOTTOM" value="0" enum="BannerAdLocation"> | ||
Indicates a banner should be located on the bottom of the screen. | ||
</constant> | ||
<constant name="BannerAdLocation::BANNER_LOCATION_TOP" value="1" enum="BannerAdLocation"> | ||
Indicates a banner should be located on the top of the screen. | ||
</constant> | ||
</constants> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="BannerAdController" inherits="AdController" version="3.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> | ||
<brief_description> | ||
Controls and configures banner ads | ||
</brief_description> | ||
<description> | ||
BannerAdController is used to set up the size, location and status of a banner advertisement, and control its status. | ||
It also includes signals inherited from AdController to monitor the status of a banner ad. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
</methods> | ||
<members> | ||
<member name="auto_show" type="bool" setter="set_auto_show" getter="get_auto_show" default="false"> | ||
When auto-show is enabled, the banner advertisement will be displayed to the user when this node enters the scene. | ||
</member> | ||
<member name="location" type="int" setter="set_location" getter="get_location" enum="AdServer.BannerAdLocation" default="0"> | ||
The location on the screen to display this banner advertisement. | ||
</member> | ||
<member name="size" type="int" setter="set_size" getter="get_size" enum="AdServer.BannerAdSize" default="0"> | ||
The size of the advertisement. | ||
This is internally converted to an appropriate value for each ad network to ensure uniform behavior across networks. | ||
</member> | ||
</members> | ||
<constants> | ||
</constants> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="DummyAdPlugin" inherits="AdPlugin" version="3.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> | ||
<brief_description> | ||
</brief_description> | ||
<description> | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
</methods> | ||
<constants> | ||
</constants> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.